-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Add documentation for METH_FASTCALL and _PyObject_FastCall*() #72991
Comments
It looks like METH_FASTCALL gives nice speedups (bpo-28754). Is this an internal interface or can it be documented like |
I suggest to keep it internal. It's meaning may be changed in future. I have some ideas about making it more convenient and faster (but I'm not sure that they would work). |
Is it possible to use Argument Clinic for third party extensions? If yes, I It would also be nice if Cython could use it automatically. So we can Serhiy Storchaka added the comment:
Ah? Can you please elaborate your secret plan? :-) |
There are a couple of problems with using Argument Clinic for third First, it makes no stability promises: "Currently Argument Clinic is considered internal-only for CPython. ..." Then, for large projects that already use some generated code (like So it would be nice to have a public stable API -- of course there |
I already said about this. Move the part of parsing keyword argument outside of the function. The caller should unpack keyword arguments and pass just a raw array of PyObject*. Missed arguments are set to NULL. This could make _PyArg_ParseStack() simpler and might even allow to inline arguments parsing code. |
This and the _PyObject_FastCall* APIs really do need to be documented, especially if they're going to be used in the interpreter itself. The leading underscore signifies that it's not part of the public API (well, METH_FASTCALL doesn't have a leading underscore). When these are not documented, then they aren't discoverable, so there are cases where it may be useful but will be overlooked. It also means that folks will be inclined to cargo cult the few existing uses without perhaps understanding the full semantics. Can we please document these for Python 3.7 at least? |
I chose to not document FASTCALL on purpose in Python 3.6, I wanted to keep everything private, until we get enough feedback and stabilize the API. Recently, the FASTCALL API changed: METH_FASTCALL doesn't support keywords anymore. You have to pass METH_FASTCALL|METH_KEYWORDS. It seems like the API became stable. I don't know if we should make the API public or not. PyPy would complain as usual that we give them more work to do :-D |
I suggest to document the following 4 functions/macros: PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
PyObject *callable,
PyObject **args,
Py_ssize_t nargs,
PyObject *kwargs);
PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords(
PyObject *callable,
PyObject **args,
Py_ssize_t nargs,
PyObject *kwnames);
#define _PyObject_FastCall(func, args, nargs) \
_PyObject_FastCallDict((func), (args), (nargs), NULL)
#define _PyObject_CallNoArg(func) \
_PyObject_FastCallDict((func), NULL, 0, NULL) And the METH_FASTCALL and METH_FASTCALL|METH_KEYWORDS calling convention. |
Cython is using FASTCALL since Python 3.6. |
Victor, of the four functions you mentioned:
So that leaves documenting METH_FASTCALL. |
PR 14079 has been merged, is there anything left as unresolved about this issue? |
Thanks, I think we can close this docs issue as completed |
Note: 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:
The text was updated successfully, but these errors were encountered: