We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1f788a commit 64aa8ebCopy full SHA for 64aa8eb
1 file changed
Lib/test/test_capi/test_opt.py
@@ -1581,6 +1581,24 @@ def testfunc(n):
1581
self.assertNotIn("_COMPARE_OP_INT", uops)
1582
self.assertIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
1583
1584
+ def test_remove_guard_for_known_type_str(self):
1585
+ def f(n):
1586
+ for i in range(n):
1587
+ false = i == TIER2_THRESHOLD
1588
+ empty = "X"[:false]
1589
+ empty += "" # Make JIT realize this is a string.
1590
+ if empty:
1591
+ return 1
1592
+ return 0
1593
+
1594
+ res, ex = self._run_with_optimizer(f, TIER2_THRESHOLD)
1595
+ self.assertEqual(res, 0)
1596
+ self.assertIsNotNone(ex)
1597
+ uops = get_opnames(ex)
1598
+ self.assertIn("_TO_BOOL_STR", uops)
1599
+ self.assertNotIn("_GUARD_TOS_UNICODE", uops)
1600
1601
1602
def global_identity(x):
1603
return x
1604
0 commit comments