-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
bpo-26110: Add CALL_METHOD_KW
opcode to speedup method calls with keywords
#26014
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
bpo-26110: Add CALL_METHOD_KW
opcode to speedup method calls with keywords
#26014
Conversation
I'll post pyperformance results here shortly (hopefully by tomorrow). Edit1: non-scientific
Edit2: pyperformance shows no significant change (once again likely because keyword args in method calls aren't common in pyperformance). |
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.
Looks good in general.
A couple of very minor issues
Mark, thanks for taking the time to review this patch. I really appreciate the feedback (it also led to some really interesting discoveries). I have made the requested changes; please review again |
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.
One unused variable. Otherwise good.
You can change STACK_SHRINK
in this PR, or a new one. Up to you.
Great. |
Thanks for all the reviews Mark! I'll watch the buildbots and hopefully nothing bad happens. |
This is the keyword counterpart for
CALL_METHOD
(which is only emitted for positional only method calls). The originalCALL_METHOD
was inspired by PyPy. Not documented there is that PyPy also has aCALL_METHOD_KW
for the same purpose.On microbenchmarks, there is a 1.2x speedup similar to the original patch by Yury for things like
X.b(1, 2, c=3, d=4)
. On pyperformance, it isn't as noticeable -- mostly because pyperformance doesn't use keyword argument calls.If accepted, docs and What's New (if necessary) will be a later patch.
A side effect of this is that
CALL_METHOD
should also be slightly faster due to the elimination of a branch.https://bugs.python.org/issue26110