-
-
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
gh-90370: avoid temporary tuple creation for vararg in AC #126064
Conversation
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) ```
I'd prefer if we could keep those changes separate. Let's nok mix features (adapt methods/functions to Argument Clinic) and performance improvements (avoid temporary tuple creation for varargs in Argument Clinic). |
Ok, reverted. Edit: description adjusted. |
This comment was marked as outdated.
This comment was marked as outdated.
Re f179557: yes, you want |
I'll let this sit a couple of days to give @pablogsal a chance to chime in on the gc module change. |
I think this one is mostly mechanical change. Temporary tuple creation was moved from AC-generated code to gc_get_referrers_impl/gc_get_referents_impl. |
Yes, but still it is good practice to give code owners a chance to have a look. |
The rest of changes (math module): #126235 |
Current patch partially address issue, working in case when all arguments either positional-only or vararg.
Objects/setobject.c and Modules/gcmodule.c adapted. This fixes slight performance regression for set methods, introduced by #115112, e.g.:
Benchmark code:
varargs
tuple creation in argument passing #90370