-
-
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
Receiving vector calls in the Py_LIMITED_API #93274
Comments
Found one more wrinkle: we probably should disable setting |
Previous discussion on fixing up tp_call: https://mail.python.org/archives/list/[email protected]/thread/KASUG5TENCSRHX5K4O6ZY4XRPHVUWFPY/#K2KBOTUW43YCYQ3CI7AI3WTRLWUF4YP3 |
Combined with exposing the call side of vectorcall ( |
PEP 590 makes it clear that
|
The issue is that if the class is mutable, |
Not a problem. cls->tp_call = ... becomes cls->tp_call = ...
cls->tp_vectorcall = NULL; |
Setting It would need to become something like:
|
Indeed, as Victor points out, it isn't cls->tp_call = ...
cls->tp_flags &= ~Py_TPFLAGS_HAVE_VECTORCALL;
cls->tp_version = 0; /* Just to be safe? */ |
We might need to invalidate sub-classes as well, it depends on whether |
Yes, the flag needs to be unset. |
PR: #95717 As for setting |
AFAICS, this is now implemented. Unless you have further changes planned, let's close this issue. |
Next up in this bucket is making vectorcalls. Or see Discourse for a bigger bucket. |
The new tests broke buildbots. I'll revert & test more thoroughly. |
pythonGH-95717)" This reverts commit 656dad7.
Fixed in #95796 |
Feature or enhancement
The
PyType_FromSpec
family of functions provides a convenient and forward-compatible way mechanism for creating new types. It could in principle also be used to create callables providing a PEP-590 vector call interface, which has significant performance benefits for binding libraries (see the related discussion here).One can already specify a member named
__vectorcalloffset__
inPyType_FromSpec
. This isn't fully working in the limited API, however. I encountered the following problems.Py_TPFLAGS_HAVE_VECTORCALL
flag is not part of the limited API.PyVectorcall_NARGS()
helper function is not part of the limited API.tp_call
to the compatibility dispatch routinePyVectorcall_Call
. It is, however, also not part of the public ABI.tp_call
unspecified is not an option.PyType_Ready()
even throws an exception intype_ready_pre_checks()
whentp_call
is unspecified.Pitch
I propose the following changes:
Py_TPFLAGS_HAVE_VECTORCALL
,PyVectorcall_NARGS()
, andPyVectorcall_Call()
to the limited API.tp_call
toPyVectorcall_Call
whenPyType_Ready
encounters a type that doesn't have this field set.Note that vector calls can be received and performed. This issue is just about the receiving end.
Previous discussion
See the discord thread https://discuss.python.org/t/ideas-for-forward-compatible-and-fast-extension-libraries-in-python-3-12/15993/12.
The text was updated successfully, but these errors were encountered: