10
10
11
11
from test .support import script_helper , requires_specialization
12
12
13
+ from _testinternalcapi import TIER2_THRESHOLD
13
14
14
15
@contextlib .contextmanager
15
16
def temporary_optimizer (opt ):
@@ -69,8 +70,8 @@ def loop():
69
70
self .assertEqual (opt .get_count (), 0 )
70
71
with clear_executors (loop ):
71
72
loop ()
72
- # Subtract 16 because optimizer doesn't kick in until 16
73
- self .assertEqual (opt .get_count (), 1000 - 16 )
73
+ # Subtract because optimizer doesn't kick in sooner
74
+ self .assertEqual (opt .get_count (), 1000 - TIER2_THRESHOLD )
74
75
75
76
def test_long_loop (self ):
76
77
"Check that we aren't confused by EXTENDED_ARG"
@@ -97,7 +98,7 @@ def long_loop():
97
98
with temporary_optimizer (opt ):
98
99
self .assertEqual (opt .get_count (), 0 )
99
100
long_loop ()
100
- self .assertEqual (opt .get_count (), 20 - 16 ) # Need 16 iterations to warm up
101
+ self .assertEqual (opt .get_count (), 20 - TIER2_THRESHOLD ) # Need iterations to warm up
101
102
102
103
def test_code_restore_for_ENTER_EXECUTOR (self ):
103
104
def testfunc (x ):
@@ -933,10 +934,10 @@ def testfunc(n):
933
934
exec (src , ns , ns )
934
935
testfunc = ns ['testfunc' ]
935
936
ns ['_test_global' ] = 0
936
- _ , ex = self ._run_with_optimizer (testfunc , 16 )
937
+ _ , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
937
938
self .assertIsNone (ex )
938
939
ns ['_test_global' ] = 1
939
- _ , ex = self ._run_with_optimizer (testfunc , 16 )
940
+ _ , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
940
941
self .assertIsNotNone (ex )
941
942
uops = get_opnames (ex )
942
943
self .assertNotIn ("_GUARD_BOTH_INT" , uops )
@@ -947,10 +948,10 @@ def testfunc(n):
947
948
exec (src , ns , ns )
948
949
testfunc = ns ['testfunc' ]
949
950
ns ['_test_global' ] = 0
950
- _ , ex = self ._run_with_optimizer (testfunc , 16 )
951
+ _ , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
951
952
self .assertIsNone (ex )
952
953
ns ['_test_global' ] = 3.14
953
- _ , ex = self ._run_with_optimizer (testfunc , 16 )
954
+ _ , ex = self ._run_with_optimizer (testfunc , TIER2_THRESHOLD )
954
955
self .assertIsNone (ex )
955
956
956
957
def test_many_nested (self ):
0 commit comments