Repository navigation
Conversation
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.
I am opening this PR to preserve surviving bindings when Python optimizes away repeated unpack targets. The code below currently overwrites the real
_binding during decompilation:It is currently reconstructed as:
For
[(1, 2, 3, 4)], the source returns[(1, 4, 2)]; the incorrect reconstruction returns[(1, 4, 3)]because the third slot overwrites_.Earlier stores to a repeated target can become
POP_TOP. Replacing every discarded slot with an invented_changes local bindings, local-name metadata and the recompilation's store/elision pattern. The same distinction applies to ordinary loop targets such asfor value, discarded, discarded, discarded in values.The parser now looks only within the unfinished unpack's direct stores and reuses the surviving local/cell target's spelling. It stops at nested unpacking, control flow or effects, and retains
_as a fallback when no surviving target is proved. Genuine underscore bindings remain distinct from eliminated stores to another name.The optimization appears in CPython 3.13's
STORE_FASToptimizer, which replaces an adjacent overwritten store on the same source line withPOP_TOP. The inference therefore starts at 3.13, including inlined list comprehensions and ordinary unpacking loops.