Skip to content

gh-145866: Convert LIST_EXTEND to leave its inputs on the stack to be cleaned up by _POP_TOP be cleaned up by _POP_TOP#146383

Open
NekoAsakura wants to merge 1 commit intopython:mainfrom
NekoAsakura:list-extend-pop-top
Open

gh-145866: Convert LIST_EXTEND to leave its inputs on the stack to be cleaned up by _POP_TOP be cleaned up by _POP_TOP#146383
NekoAsakura wants to merge 1 commit intopython:mainfrom
NekoAsakura:list-extend-pop-top

Conversation

@NekoAsakura
Copy link
Contributor

@NekoAsakura NekoAsakura commented Mar 24, 2026

Comment on lines 4051 to +4066
def test_binary_subscr_list_slice(self):
def testfunc(n):
x = 0
for _ in range(n):
l = [1, 2, 3]
x += l[0:1][0]
return x

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
uops = get_opnames(ex)

self.assertIn("_BINARY_OP_SUBSCR_LIST_SLICE", uops)
self.assertNotIn("_GUARD_TOS_LIST", uops)
self.assertEqual(count_ops(ex, "_POP_TOP"), 3)
self.assertEqual(count_ops(ex, "_POP_TOP_NOP"), 4)
self.assertEqual(count_ops(ex, "_POP_TOP_NOP"), 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we move l = [1, 2, 3] outside the loop, so that _LIST_EXTEND wouldn't be in the trace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants