Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-100146: Steal references from stack when building a list#100147
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
d223e29
to808385c
CompareWhen executing the BUILD_LIST opcode, steal the references from the stack,in a manner similar to the BUILD_TUPLE opcode. Implement this by offloadingthe logic to a new private API, _PyList_FromArraySteal(), that works similarlyto _PyTuple_FromArraySteal().This way, instead of performing multiple stack pointer adjustments while thelist is being initialized, the stack is adjusted only once and a fast memorycopy operation is performed in one fell swoop.
808385c
to9379cd4
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, looks good to me. We probably won't be able to prove this improves performance, but I don't doubt that plenty of code will benefit from such a micro-optimization.
Ping me Monday about merging it.
bedevere-bot commentedDec 10, 2022
🤖 New build scheduled with the buildbot fleet by@gvanrossum for commit9379cd4 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
I've requested a buildbot build to make sure there isn't some dumb issue with refleaks. |
Improve ``BUILD_LIST`` opcode so that it works similarly to the | ||
``BUILD_TUPLE`` opcode, by stealing references from the stack rather than | ||
repeatedly using stack operations to set list elements. Implementation | ||
details are in a new private API :c:func:`_PyList_FromArraySteal`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
details are in a new private API:c:func:`_PyList_FromArraySteal`. | |
details are in a new private API:c:func:`!_PyList_FromArraySteal`. |
No need to link to private functions.
Improve ``BUILD_LIST`` opcode so that it works similarly to the | ||
``BUILD_TUPLE`` opcode, by stealing references from the stack rather than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Improve``BUILD_LIST`` opcodeso that it works similarly tothe | |
``BUILD_TUPLE`` opcode, by stealing references from the stack rather than | |
Improve:opcode:`BUILD_LIST`so that it works similarly to | |
:opcode:`BUILD_TUPLE`, by stealing references from the stack rather than |
I don't know what's up with the ARM64 Windows buildbot, but it's been failing the same way for at least three days, so no need to worry that this PR could somehow have made it go red. |
Uh oh!
There was an error while loading.Please reload this page.
Thanks, this looks solid. |
Uh oh!
There was an error while loading.Please reload this page.
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.