-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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 PyHeap_GetType() to limited C API to get the value of ht_type from heap types using PyObject pointer. #128351
Comments
There's no need for that. You can use the return value from |
When building and testing my updated code, I normally use What I discovered is that somehow my code caused the interpreter to crash within the inline function for |
Can you show us your code? |
I can share it privately if possible. |
You can invite me to a private repo where you have a reproducer. Otherwise, can you give us a reproducer which is like your private code but without the private parts (namely just show us how you declared your types and registered them). I don't see a connection with vector call functions. Are you sure the crash doesn't happen due to other reasons (like a dereferenced pointer being NULL)? I don't think we need to expose such API and I would still think we need a more specific use case and example of usage (and/or how a simple cuatom type implementing vectorcalls would crash). |
+1. Closing as not-a-bug. If you need help with the C APIs, please see the docs or create a topic on Discourse. |
Feature or enhancement
Proposal:
Currently on the Limited C API one can use
PyType_FromSpec()
using a spec for a type to obtain a special heap type object. However, in order to then callPyModule_AddObject
to bind the resulting type object created from this to the module one must first access thePyHeapTypeObject
structure which is sadly not defined at all, nor any of it's members when using the limited C API.The only workaround for this would be a new
PyHeap_GetType()
to obtain the value (PyTypeObject *
) from the inputPyHeapTypeObject
as aPyObject *
without first casting the result fromPyType_FromSpec
toPyHeapTypeObject
. The result is then better usage in C extensions wanting to use the limited API but cannot due to this limitation.Alternatives as well:
PyType_FromSpec
for the limited API that takes in the module object (PyObject *
) and calls thePyModule_AddObject
function for the user so they never need to worry about heap type object stuffs.Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
I seen discussions about allowing
PyHeapTypeObject
in C extensions on GitHub in the past, but no idea how far the progress is currently on that. I think havingPyHeap_GetType
or whatever name of a function it could be and/or a function that internally callsPyType_FromSpec
ANDPyModule_AddObject
for C extension developers exposed to the C API could work as well.See also: #105970 (there could be more)
The text was updated successfully, but these errors were encountered: