-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Description
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 call PyModule_AddObject
to bind the resulting type object created from this to the module one must first access the PyHeapTypeObject
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 input PyHeapTypeObject
as a PyObject *
without first casting the result from PyType_FromSpec
to PyHeapTypeObject
. The result is then better usage in C extensions wanting to use the limited API but cannot due to this limitation.
Alternatives as well:
- A copy of
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 having PyHeap_GetType
or whatever name of a function it could be and/or a function that internally calls PyType_FromSpec
AND PyModule_AddObject
for C extension developers exposed to the C API could work as well.
See also: #105970 (there could be more)