Skip to content

bpo-46329: Avoid PUSH_NULL when followed by LOAD_GLOBAL #31933

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

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Mar 16, 2022

Uses the low bit of LOAD_GLOBAL's oparg to indicate whether it should push a NULL first.

len(alist)

now compiles to

LOAD_GLOBAL              1 (NULL + len)
LOAD_FAST                0 (alist)
PRECALL                  1
CALL                     1

This reduces the total number of VM instructions executed by ~2%.

The benchmark results show an unlikely 3% speedup, probably just one of those random build variations.

https://bugs.python.org/issue46329

@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 17, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @markshannon for commit 198517e 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 17, 2022
@markshannon
Copy link
Member Author

Buildbot failures seem unrelated to this PR: 2 pre-existing failures and one asyncio timeout.

@markshannon markshannon merged commit 3011a09 into python:main Mar 17, 2022
@MatthieuDartiailh
Copy link
Contributor

I may be missing something but shouldn't the computation for the stack effect of LOAD_GLOBAL be also adjusted since it can now push 2 elements on the stack ?

@markshannon markshannon deleted the merge-push-null-load-global branch September 26, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants