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 8097826 commit 218dc00Copy full SHA for 218dc00
Lib/test/test_capi/test_opt.py
@@ -1782,6 +1782,22 @@ def testfunc(n):
1782
self.assertNotIn("_GUARD_NOS_NULL", uops)
1783
self.assertNotIn("_GUARD_CALLABLE_TYPE_1", uops)
1784
1785
+ def test_call_type_1_result_is_const(self):
1786
+ def testfunc(n):
1787
+ x = 0
1788
+ for _ in range(n):
1789
+ t = type(42)
1790
+ if t is not None: # guard is removed
1791
+ x += 1
1792
+ return x
1793
+
1794
+ res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1795
+ self.assertEqual(res, TIER2_THRESHOLD)
1796
+ self.assertIsNotNone(ex)
1797
+ uops = get_opnames(ex)
1798
+ self.assertIn("_CALL_TYPE_1", uops)
1799
+ self.assertNotIn("_GUARD_IS_NOT_NONE_POP", uops)
1800
1801
1802
def global_identity(x):
1803
return x
0 commit comments