Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test case
  • Loading branch information
noamcohen97 committed Jun 28, 2025
commit 6c04f676c774b5f37766f35f2b5cbc66c649e573
13 changes: 13 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,19 @@ def testfunc(n):
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)

def test_call_isinstance_guards_pop_top(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't leave a comment on that line, but inside test_call_isinstance_guards_removed we should include the new opcode _SWAP_CALL_TWO_LOAD_CONST_INLINE_BORROW to ensure remove_unneeded_uops is still working as expected (I think it should be since you also updated op_without_push, but just to be sure :))

def testfunc(n):
x = 0
for _ in range(n):
x += isinstance(42, int)
return x

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_POP_TOP_NOP", uops)

def test_call_list_append(self):
def testfunc(n):
a = []
Expand Down