Skip to content

Commit c9cd8f2

Browse files
add test
1 parent 00818c8 commit c9cd8f2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,21 @@ def testfunc(n):
23402340
self.assertIn("_BINARY_OP_SUBSCR_DICT_KNOWN_HASH", uops)
23412341
self.assertNotIn("_BINARY_OP_SUBSCR_DICT", uops)
23422342

2343+
2344+
def test_binary_op_subscr_constant_frozendict_known_hash(self):
2345+
def testfunc(n):
2346+
x = 0
2347+
for _ in range(n):
2348+
x += FROZEN_DICT_CONST['x']
2349+
return x
2350+
2351+
res, ex = self._run_with_optimizer(testfunc, 2 * TIER2_THRESHOLD)
2352+
self.assertEqual(res, 2 * TIER2_THRESHOLD)
2353+
self.assertIsNotNone(ex)
2354+
uops = get_opnames(ex)
2355+
self.assertNotIn("_BINARY_OP_SUBSCR_DICT_KNOWN_HASH", uops)
2356+
self.assertNotIn("_BINARY_OP_SUBSCR_DICT", uops)
2357+
23432358
def test_store_subscr_dict_known_hash(self):
23442359
# str, int, bytes, float, complex, tuple and any python object which has generic hash
23452360
def testfunc(n):

0 commit comments

Comments
 (0)