-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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 METH_VARARGS
in clinic code
#117873
Comments
Just yesterday I tried to write a patch which makes parameters of the C accelerators for Making parameters positional-only by default is an interesting idea, but it would require rewriting a lot of existing Argument Clinic declarations. It is difficult to do without manually, you have to write a conversion script. It would also differ from current defaults for Python function, it can cause different kind of errors. So I think that it is easier to just be careful when write new Argument Clinic declarations and don't add keyword support without need. |
@serhiy-storchaka: one thought could be to have Argument Clinic emit a warning for varargs. (I get the feeling we've discussed this before.) |
Currently, you can use
|
I wrote PR gh-118010 for the |
* shm_unlink() parameter becomes positional-only. * shm_open() first parameter (path) becomes positional-only, the two following parameters remain positional-or-keyword.
I wrote PR gh-118012 for the |
This comment was marked as resolved.
This comment was marked as resolved.
METH_VARARGS is inefficient, but I don't see why do you want to avoid "METH_FASTCALL|METH_KEYWORDS". Accepting keywords has no cost if arguments are passed as keywords. Also, sometimes, passing keywords makes an API way better. Replacing METH_VARARGS with METH_FASTCALL is a nice goal, but there are some limitation, Argument Clinic is quite complicated, especially when it comes to option groups. |
Is there a difference in performance between |
See the C API docs. Very often you will find answers to your questions in the docs; if the docs are missing information, it is a documentation bug (and in that case, you can file a bug report so we can improve the docs). |
It doesn't say anything about performance, I'll file a bug report. |
Ok, I converted my two PRs a draft until main becomes Python 3.14 (next month). |
METH_VARARGS
in clinic code
* shm_unlink() parameter becomes positional-only. * shm_open() first parameter (path) becomes positional-only, the two following parameters remain positional-or-keyword.
METH_VARARGS
in clinic codeMETH_VARARGS
in clinic code
* shm_unlink() parameter becomes positional-only. * shm_open() first parameter (path) becomes positional-only, the two following parameters remain positional-or-keyword.
* shm_unlink() parameter becomes positional-only. * shm_open() first parameter (path) becomes positional-only, the two following parameters remain positional-or-keyword.
I'll close this. It would be better to optimise |
Feature or enhancement
Proposal:
Note: PR's for this should tackle a couple modules at a time.
We should avoid code like this in private clinic functions which aren't exported as public:
cpython/Modules/posixmodule.c
Lines 5470 to 5476 in 8fc953f
This causes a lot of overhead with no practical benefit:
cpython/Modules/clinic/posixmodule.c.h
Lines 2257 to 2304 in 8fc953f
If we wrote this instead:
The overhead is gone:
No, I didn't forget to include the rest of the code, this is all the code!
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Linked PRs
os.path
#118035The text was updated successfully, but these errors were encountered: