Currently, the BUILD_LIST opcode adjusts the stack multiple times while items are popped one by one from the stack, rather than employing the more efficient method used by BUILD_TUPLE (that steals the references from the stack).
When executing the BUILD_LIST opcode, steal the references from the stack,
in a manner similar to the BUILD_TUPLE opcode. Implement this by offloading
the logic to a new private API, _PyList_FromArraySteal(), that works similarly
to _PyTuple_FromArraySteal().
This way, instead of performing multiple stack pointer adjustments while the
list is being initialized, the stack is adjusted only once and a fast memory
copy operation is performed in one fell swoop.
lpereira
added a commit
to lpereira/cpython
that referenced
this issue
Dec 9, 2022
When executing the BUILD_LIST opcode, steal the references from the stack,
in a manner similar to the BUILD_TUPLE opcode. Implement this by offloading
the logic to a new private API, _PyList_FromArraySteal(), that works similarly
to _PyTuple_FromArraySteal().
This way, instead of performing multiple stack pointer adjustments while the
list is being initialized, the stack is adjusted only once and a fast memory
copy operation is performed in one fell swoop.
lpereira commentedDec 9, 2022
•
edited by bedevere-bot
Currently, the
BUILD_LIST
opcode adjusts the stack multiple times while items are popped one by one from the stack, rather than employing the more efficient method used byBUILD_TUPLE
(that steals the references from the stack).Linked PRs
The text was updated successfully, but these errors were encountered: