Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
gvanrossum merged 1 commit intopython:mainfromlpereira:build-list-stack-steal
Jan 3, 2023

Conversation

lpereira
Copy link
Contributor

@lpereiralpereira commentedDec 9, 2022
edited by bedevere-bot
Loading

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.

mdboom reacted with thumbs up emoji
When 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.
Copy link
Member

@gvanrossumgvanrossum left a 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.

@gvanrossumgvanrossum added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 10, 2022
@bedevere-bot
Copy link

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

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 10, 2022
@pythonpython deleted a comment fromnetlifybotDec 10, 2022
@gvanrossum
Copy link
Member

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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.

Comment on lines +1 to +2
Improve ``BUILD_LIST`` opcode so that it works similarly to the
``BUILD_TUPLE`` opcode, by stealing references from the stack rather than
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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

@gvanrossum
Copy link
Member

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.

@gvanrossumgvanrossum merged commite6d4440 intopython:mainJan 3, 2023
@gvanrossum
Copy link
Member

Thanks, this looks solid.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iritkatrieliritkatrieliritkatriel left review comments

@gvanrossumgvanrossumgvanrossum approved these changes

@markshannonmarkshannonmarkshannon left review comments

@kumaraditya303kumaraditya303kumaraditya303 approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@lpereira@bedevere-bot@gvanrossum@iritkatriel@markshannon@kumaraditya303

[8]ページ先頭

©2009-2025 Movatter.jp