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
Open
Conversation
…ck to be cleaned up by `_POP_TOP`
Sacul0457
reviewed
Mar 25, 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) |
Contributor
There was a problem hiding this comment.
should we move l = [1, 2, 3] outside the loop, so that _LIST_EXTEND wouldn't be in the trace?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_POP_TOP#145866