8000 gh-106529: Split FOR_ITER_{LIST,TUPLE} into uops by gvanrossum · Pull Request #106696 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-106529: Split FOR_ITER_{LIST,TUPLE} into uops #106696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 14, 2023
Merged
Prev Previous commit
Next Next commit
Add test for FOR_ITER_LIST in Tier 2
  • Loading branch information
gvanrossum committed Jul 12, 2023
commit 3f3a9e8fd9f84a63d0497fa2d7089c28d239bede
23 changes: 22 additions & 1 deletion Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,6 @@ def testfunc(n):
for i in range(n):
total += i
return total
# import dis; dis.dis(testfunc)

opt = _testinternalcapi.get_uop_optimizer()
with temporary_optimizer(opt):
Expand All @@ -2606,6 +2605,28 @@ def testfunc(n):
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

def test_for_iter_list(self):
def testfunc(a):
total = 0
for i in a:
total += i
return total

opt = _testinternalcapi.get_uop_optimizer()
with temporary_optimizer(opt):
a = list(range(10))
total = testfunc(a)
self.assertEqual(total, 45)

ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _ in ex}
self.assertIn("_ITER_EXHAUSTED_LIST", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output


if __name__ == "__main__":
unittest.main()
0