Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUILD_LIST should steal references, similar to BUILD_TUPLE #100146

Closed
lpereira opened this issue Dec 9, 2022 · 1 comment
Closed

BUILD_LIST should steal references, similar to BUILD_TUPLE #100146

lpereira opened this issue Dec 9, 2022 · 1 comment
Labels
type-feature A feature request or enhancement

Comments

@lpereira
Copy link
Contributor

lpereira commented Dec 9, 2022

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).

Linked PRs

@lpereira lpereira added the type-feature A feature request or enhancement label Dec 9, 2022
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 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.
gvanrossum pushed a commit that referenced this issue Jan 3, 2023
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.
@hauntsaninja
Copy link
Contributor

Looks like this has been completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants