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
585
585
generate line tracing events.
586
586
587
587
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
+
588
604
.. opcode :: POP_TOP
589
605
590
606
Removes the top-of-stack item::
Original file line number Diff line number Diff line change 15
15
16
16
_testinternalcapi = import_helper .import_module ("_testinternalcapi" )
17
17
18
- from _testinternalcapi import TIER2_THRESHOLD
18
+ from _testinternalcapi import _PY_NSMALLPOSINTS , TIER2_THRESHOLD
19
19
20
20
#For test of issue 136154
21
21
GLOBAL_136154 = 42
@@ -2093,6 +2093,10 @@ def testfunc(n):
2093
2093
self .assertNotIn ("_GUARD_TOS_INT" , uops )
2094
2094
2095
2095
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
+
2096
2100
def testfunc (n ):
2097
2101
x = 0
2098
2102
for _ in range (n ):
@@ -2113,13 +2117,17 @@ def testfunc(n):
2113
2117
self .assertNotIn ("_POP_TOP_LOAD_CONST_INLINE_BORROW" , uops )
2114
2118
2115
2119
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
+
2116
2124
def testfunc (n ):
2117
2125
class C :
2118
- t = tuple (range (300 ))
2126
+ t = tuple (range (2048 ))
2119
2127
2120
2128
x = 0
2121
2129
for _ in range (n ):
2122
- if len (C .t ) == 300 : # comparison + guard removed
2130
+ if len (C .t ) == 2048 : # comparison + guard removed
2123
2131
x += 1
2124
2132
return x
2125
2133
Original file line number Diff line number Diff line change 34
34
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
35
35
#include "pycore_pylifecycle.h" // _PyInterpreterConfig_InitFromDict()
36
36
#include "pycore_pystate.h" // _PyThreadState_GET()
37
+ #include "pycore_runtime_structs.h" // _PY_NSMALLPOSINTS
37
38
#include "pycore_unicodeobject.h" // _PyUnicode_TransformDecimalAndSpaceToASCII()
38
39
39
40
#include "clinic/_testinternalcapi.c.h"
@@ -2576,6 +2577,10 @@ module_exec(PyObject *module)
2576
2577
return 1 ;
2577
2578
}
2578
2579
2580
+ if (PyModule_AddIntMacro (module , _PY_NSMALLPOSINTS ) < 0 ) {
2581
+ return 1 ;
2582
+ }
2583
+
2579
2584
return 0 ;
2580
2585
}
2581
2586
You can’t perform that action at this time.
0 commit comments