-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Avoid temporary varargs
tuple creation in argument passing
#90370
Comments
When "Augument Clinic generated code" are parsing arguments, the args are packed to a tuple before passing to callee. This may be unnecessary. Pass a raw pointer which points to on-stack varargs, and a varargssize integer to indicate how many varargs are passed, can save the time of tuple creation/destruction and value copy. |
I wrote some microbenchs. Patch: b68176d Environment: Result on microbench:
|
Note that _PyArg_UnpackKeywordsWithVararg is defined with PyAPI_FUNC. Changing its argument spec is strictly a backwards incompatible change, IIUC. |
I am a rookie in Python, did not notice changing PyAPI_FUNC means breaking backward compatibility. I have reverted _PyArg_UnpackKeywordsWithVararg and committed again. |
AFAIK we have committed _PyArg_UnpackKeywordsWithVararg on 3.11 alpha, so I think it should be fine. Also CC: @pablogsal |
I see, so no ABI worries then. |
It seems #30312 was abandoned by author. I'll continue this work. |
Current patch partially address issue, working in case when all arguments either positional-only or vararg. This also converts gcd(), lcm() and hypot() functions of the math module to the Argument Clinic. Fix issue python#101123. Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by python#115112: | Benchmark | ref | patch | |----------------------|:------:|:--------------------:| | set().update(s1, s2) | 354 ns | 264 ns: 1.34x faster | Benchmark code: ```py import pyperf s1, s2 = {1}, {2} runner = pyperf.Runner() runner.bench_func('set().update(s1, s2)', set().update, s1, s2) ```
#126064 is ready for review (partially address issue) |
@erlend-aasland, I'm not sure we can mark this a fixed issue. The merged pr covers only part of the original proposal (e.g. it doesn't work for the OP example with print()). |
varargs
tuple creation in argument passing #30312Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: