File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -585,6 +585,22 @@ operations on it as if it was a Python list. The top of the stack corresponds to
585585 generate line tracing events.
586586
587587
588+ .. opcode :: NOT_TAKEN
589+
590+ Do nothing code.
591+ Used by the interpreter to record :monitoring-event: `BRANCH_LEFT `
592+ and :monitoring-event: `BRANCH_RIGHT ` events for :mod: `sys.monitoring `.
593+
594+ .. versionadded :: 3.14
595+
596+
597+ .. opcode :: POP_ITER
598+
599+ Removes the iterator from the top of the stack.
600+
601+ .. versionadded :: 3.14
602+
603+
588604.. opcode :: POP_TOP
589605
590606 Removes the top-of-stack item::
Original file line number Diff line number Diff line change 1515
1616_testinternalcapi = import_helper .import_module ("_testinternalcapi" )
1717
18- from _testinternalcapi import TIER2_THRESHOLD
18+ from _testinternalcapi import _PY_NSMALLPOSINTS , TIER2_THRESHOLD
1919
2020#For test of issue 136154
2121GLOBAL_136154 = 42
@@ -2093,6 +2093,10 @@ def testfunc(n):
20932093 self .assertNotIn ("_GUARD_TOS_INT" , uops )
20942094
20952095 def test_call_len_known_length_small_int (self ):
2096+ # Make sure that len(t) is optimized for a tuple of length 5.
2097+ # See https://github.com/python/cpython/issues/139393.
2098+ self .assertGreater (_PY_NSMALLPOSINTS , 5 )
2099+
20962100 def testfunc (n ):
20972101 x = 0
20982102 for _ in range (n ):
@@ -2113,13 +2117,17 @@ def testfunc(n):
21132117 self .assertNotIn ("_POP_TOP_LOAD_CONST_INLINE_BORROW" , uops )
21142118
21152119 def test_call_len_known_length (self ):
2120+ # Make sure that len(t) is not optimized for a tuple of length 2048.
2121+ # See https://github.com/python/cpython/issues/139393.
2122+ self .assertLess (_PY_NSMALLPOSINTS , 2048 )
2123+
21162124 def testfunc (n ):
21172125 class C :
2118- t = tuple (range (300 ))
2126+ t = tuple (range (2048 ))
21192127
21202128 x = 0
21212129 for _ in range (n ):
2122- if len (C .t ) == 300 : # comparison + guard removed
2130+ if len (C .t ) == 2048 : # comparison + guard removed
21232131 x += 1
21242132 return x
21252133
Original file line number Diff line number Diff line change 3434#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
3535#include "pycore_pylifecycle.h" // _PyInterpreterConfig_InitFromDict()
3636#include "pycore_pystate.h" // _PyThreadState_GET()
37+ #include "pycore_runtime_structs.h" // _PY_NSMALLPOSINTS
3738#include "pycore_unicodeobject.h" // _PyUnicode_TransformDecimalAndSpaceToASCII()
3839
3940#include "clinic/_testinternalcapi.c.h"
@@ -2576,6 +2577,10 @@ module_exec(PyObject *module)
25762577 return 1 ;
25772578 }
25782579
2580+ if (PyModule_AddIntMacro (module , _PY_NSMALLPOSINTS ) < 0 ) {
2581+ return 1 ;
2582+ }
2583+
25792584 return 0 ;
25802585}
25812586
You can’t perform that action at this time.
0 commit comments