GH-120024: Change LOAD_FAST
instructions to LOAD_FAST_TEMP
when it is guaranteed the reference is consumed immediately.
#125192
+484
−262
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.
This PR adds a
LOAD_FAST_TEMP
instruction for loading locals to the evaluation stack that are used as short-lived values within an expression. Distinguishing theseLOAD_FAST
instructions will allow us to avoid expensive reference counting operations in these cases.This is marked as draft, as it has no value until the default build supports reference counts in tags.
The stats show that 3/4 of all
LOAD_FAST
(including theLOAD_FAST
s inLOAD_FAST_LOAD_FAST
) are converted toLOAD_FAST_TEMP
.Before merging, a few tests need fixing and the choice of superinstructions needs updating.