I propose to port python-ldap to PEP 630. Actually, I have already done the work and have a working prototype. PEP 630 is an informational PEP that covers three PEPs
- PEP 384 – Defining a Stable ABI
- PEP 489 – Multi-phase extension module initialization
- PEP 573 – Module State Access from C Extension Methods
Isolated C extension module will give us two major benefits:
- Stable ABI / limited API will allow us / our users to create
abi3 binary wheels. My prototype implements cp36-abi3-linux_x86_64.whl support. The wheels is compatible with all Python versions from 3.6 to 3.12, as well as future versions of Python 3 with ABI3. For example @cgohlke won't need to create Windows binaries for each Python version.
- It makes python-ldap compatible with PEP 684 Per-Interpreter GIL and safe to use with multiple subinterpreters.
Required changes
I propose to port python-ldap to PEP 630. Actually, I have already done the work and have a working prototype. PEP 630 is an informational PEP that covers three PEPs
Isolated C extension module will give us two major benefits:
abi3binary wheels. My prototype implementscp36-abi3-linux_x86_64.whlsupport. The wheels is compatible with all Python versions from 3.6 to 3.12, as well as future versions of Python 3 with ABI3. For example @cgohlke won't need to create Windows binaries for each Python version.Required changes
PyTypeObject LDAP_Typeto heap type.PyTypeObject LDAP_TypewithPyType_SlotandPyType_SpecPyObject_GC_Newand free it withPyObject_GC_UnTrack/PyObject_GC_DelPyType_FromSpec_ldapC extension module with multi-phase initializationfunctions.candldapcontrol.c. This also gets rid ofLDAPadd_methodshack,LDAPinit_functions, andLDAPinit_controlPyModuleDef_Slotto init type, constants, and pkginfoPyModuleDefglobal staticPyModuleDef_InitLDAP_Type,LDAPexception_class, anderrobjectsin favor of module state struct.LDAPModStateand add it toPyModuleDefLDAPObject.PyType_GetModuleState()is not available in Python < 3.9 and became part of the stable ABI in 3.10.LDAPerror.PySequence_Fast_GET_ITEM()withPySequence_GetItem(). We use unsafe macros in a few places. In theory the macros are a tiny bit faster. In practice it doesn't make a difference except for lots of calls in a hot path. I don't except a performance impact._ldapextension module with limited API and stable ABI parameters.