Refactor RETURN_VALUE
and RETURN_CONST
#125837
Labels
3.14
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
The
RETURN_VALUE
andRETURN_CONST
instructions return the value on top of the stack and a constant, respectively.RETURN_CONST
is effectively a superinstruction:LOAD_CONST + RETURN_VALUE
.This worked well up to 3.13, but is likely to be an impediment to further optimizations:
RETURN_CONST
intoLOAD_CONST
andRETURN_VALUE
so the superinstruction has no value.RETURN_VALUE
has two different paths internally, one for normal functions and the other for generators. We know statically which sort of function we are in, so we should emit different bytecodes for the different behaviorChanges to the instruction set:
RETURN_CONST
andINSTRUMENTED_RETURN_CONST
will be removed.RETURN_VALUE_GEN
,INSTRUMENTED_RETURN_GEN
andLOAD_CONST_IMMORTAL
will be added.We expect that
LOAD_CONST_IMMORTAL
will be removed again before 3.14, but that is not a requirement.Linked PRs
LOAD_CONST
into three. #125972The text was updated successfully, but these errors were encountered: