gh-90370: Avoid temporary varargs tuple creation in argument passing#30312
gh-90370: Avoid temporary varargs tuple creation in argument passing#30312colorfulappl wants to merge 27 commits into
varargs tuple creation in argument passing#30312Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Sorry, something went wrong.
…keep backward compatibility
sweeneyde
left a comment
There was a problem hiding this comment.
Just a couple of comments here.
I wonder if it would be simpler to restrict the scope of such a change to only signatures like def f(*args, kw1=<default1>, kw2=<default2>, ...), like print()/min()/max() have.
Sorry, something went wrong.
|
Thanks for the PR and benchmarks @colorfulappl, I am current blocked a bit but plan to review this soon! |
Sorry, something went wrong.
Thank you @isidentical ! |
Sorry, something went wrong.
|
Sure, then just ping me whenever the new patch ready and I'll try to take a look at it then! |
Sorry, something went wrong.
# Conflicts: # Python/clinic/bltinmodule.c.h
|
Sorry for such a long delay. When generate parsing code for function with varargs, this PR:
I'd really appreciate it if you could take a look and give me some advice @isidentical . |
Sorry, something went wrong.
|
Benchmark Result Benchmark: Environment: |
Sorry, something went wrong.
|
I found there are some bugs when argument clinic processes varargs and made a fix in #32092. |
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Thanks for the advice; I will pay attention to it. I added some test cases for the class method e.g. # Signature of this function:
#
# @classmethod
# _testclinic.TestClassVarargOnly.__new__(cls, *args)
test_class_new_vararg_only(kw=1)
# Here we expect an error like "TypeError: TestClassVarargOnly.__new__() got an unexpected keyword argument 'kw'",
# but nothing raised.We may need to fix it in another issue. |
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Not sure, if this is a good idea, but could you consider using nargs instead of varargsize for *_impl() functions? This will reduce needs for changing the body of converted function (take math_gcd as an example to convert from scratch). |
Sorry, something went wrong.
This patch intends to reduce the overhead on passing Before this patch,
@skirpichev Do you mean pass both
|
Sorry, something went wrong.
|
Indeed, my suggestion only valid for only-vararg case (as gcd, lcm and so on). Not sure if this case worth a special treatment... |
Sorry, something went wrong.
varargs tuple creation in argument passing|
Thanks for your work, but this has merge conflicts. Also, issue seems to be fixed. I'm closing this. |
Sorry, something went wrong.
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.
varargstuple creation in argument passing #90370