-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Remove DELETE_FAST bytecode instruction #145749
Copy link
Copy link
Open
Labels
3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
Metadata
Metadata
Assignees
Labels
3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
DELETE_FASThas two uses:delete varwherevaris a local variableA local variable can be deleted with the sequence
PUSH_NULL; STORE_FAST var.Deleting a local variable
Instead of
DELETE_FAST nwe can emitLOAD_FAST n; POP_TOP n; PUSH_NULL; STORE_FAST nwhich the bytecode optimizer will reduce toPUSH_NULL; STORE_FAST nin most cases.Cleaning up at the end of a named exception block.
We currently emit the sequence:
LOAD_CONST None; STORE_FAST n; DELETE_FAST nwhich can be replaced with
PUSH_NULL; STORE_FAST nThis case is far more common than explicitly deleting a local variable, so we can reduce code size as well as freeing up an opcode.
See faster-cpython/ideas#490
Linked PRs