-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Description
Feature or enhancement
Proposal:
See PEP 793. I'll copy the abstract for reference:
In this PEP, we propose a new entry point for C extension modules, by which one can define a module using an array of
PyModuleDef_Slotstructures without an enclosingPyModuleDefstructure. This allows extension authors to avoid using a statically allocatedPyObject, lifting the most common obstacle to making one compiled library file usable with both regular and free-threaded builds of CPython.To make this viable, we also specify new module slot types to replace
PyModuleDef’s fields, and to allow adding a token similar to thePy_tp_tokenused for type objects.We also add an API for defining modules from slots dynamically.
The existing API (
PyInit_*) is soft-deprecated. (That is: it will continue to work without warnings, and it’ll be fully documented and supported, but we plan to not add any new features to it.)
- Initial implementation (gh-140550: Initial implementation of PEP 793 – PyModExport #140556)
- Docs:
- Reference docs (gh-140550: PEP 793 reference documentation #141197)
- Soft-deprecate
PyInit_*(gh-140550: PEP 793 reference documentation #141197) - Better explanation of module state
- Give an example for tokens
- Soft-deprecate
- What's New
- Porting guide HOWTO
- Tutorial update
- Reference docs (gh-140550: PEP 793 reference documentation #141197)
-
xxlimited.cupdate - Remove the
PyInitfunction fromLib/test/test_cext/extension.c
Optional stretch goals:
- Speed & size improvements
- No longer require
spec.nameinPyModule_FromSlotsAndSpec - No longer require static allocation for
Py_mod_methods - Add a
PyModule_GetStateWithToken()function
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response