Skip to content

Commit 9c6efcb

Browse files
committed
fix review idea
Signed-off-by: Manjusaka <me@manjusaka.me>
1 parent 9adefc3 commit 9c6efcb

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ def testfunc(n):
19251925
self.assertNotIn("_GUARD_NOS_INT", uops)
19261926
self.assertNotIn("_GUARD_TOS_INT", uops)
19271927

1928-
def test_get_len_with_tuple(self):
1928+
def test_get_len_with_const_tuple(self):
19291929
def testfunc(n):
19301930
x = ""
19311931
for _ in range(n):
@@ -1940,6 +1940,21 @@ def testfunc(n):
19401940
self.assertIn("_GET_LEN", uops)
19411941
self.assertIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
19421942

1943+
def test_get_len_with_non_const_tuple(self):
1944+
def testfunc(n):
1945+
x = ""
1946+
for _ in range(n):
1947+
match (object(), object()):
1948+
case [_, _]:
1949+
x += "1"
1950+
return x
1951+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1952+
self.assertEqual(len(res), TIER2_THRESHOLD)
1953+
uops = get_opnames(ex)
1954+
self.assertNotIn("_GUARD_NOS_INT", uops)
1955+
self.assertIn("_GET_LEN", uops)
1956+
self.assertIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
1957+
19431958
def test_get_len_with_non_tuple(self):
19441959
def testfunc(n):
19451960
x = ""

0 commit comments

Comments
 (0)