Skip to content

Commit bcc36ef

Browse files
committed
Add testcase for _ITER_CHECK_LIST
1 parent 1490bd8 commit bcc36ef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3858,6 +3858,20 @@ def testfunc(n):
38583858
self.assertIn("_POP_TOP_NOP", uops)
38593859
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
38603860

3861+
def test_iter_check_list(self):
3862+
def testfunc(n):
3863+
x = 0
3864+
for _ in range(n):
3865+
l = [1]
3866+
for num in l: # unguarded
3867+
x += num
3868+
return x
3869+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
3870+
self.assertEqual(res, TIER2_THRESHOLD)
3871+
uops = get_opnames(ex)
3872+
3873+
self.assertIn("_BUILD_LIST", uops)
3874+
self.assertNotIn("_ITER_CHECK_LIST", uops)
38613875

38623876
def test_143026(self):
38633877
# https://github.com/python/cpython/issues/143026

0 commit comments

Comments
 (0)