Skip to content

Commit

Permalink
Revert "Fix test_long_loop() (sort of)"
Browse files Browse the repository at this point in the history
The test passes again!

This reverts commit 0caa9f9.
  • Loading branch information
gvanrossum committed Dec 9, 2023
1 parent 0b36d3b commit c2f00b0
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,20 +2411,14 @@ def loop():
self.assertEqual(opt.get_count(), 1000)

def test_long_loop(self):
# Check that we aren't confused by EXTENDED_ARG
"Check that we aren't confused by EXTENDED_ARG"

# Generate a new function at each call
ns = {}
exec(textwrap.dedent("""
def nop():
pass
def short_loop():
for _ in range(10):
nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
def long_loop():
for _ in range(10):
nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
Expand All @@ -2435,21 +2429,14 @@ def long_loop():
nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
nop(); nop(); nop(); nop(); nop(); nop(); nop(); nop();
"""), ns, ns)
short_loop = ns['short_loop']
long_loop = ns['long_loop']

opt = _testinternalcapi.get_counter_optimizer()
with temporary_optimizer(opt):
self.assertEqual(opt.get_count(), 0)
short_loop()
long_loop()
self.assertEqual(opt.get_count(), 10)

opt = _testinternalcapi.get_counter_optimizer()
with temporary_optimizer(opt):
self.assertEqual(opt.get_count(), 0)
long_loop() # Should not optimize!
self.assertEqual(opt.get_count(), 0)

def test_code_restore_for_ENTER_EXECUTOR(self):
def testfunc(x):
i = 0
Expand Down

0 comments on commit c2f00b0

Please sign in to comment.