-
Notifications
You must be signed in to change notification settings - Fork 135
Closed as not planned
Closed as not planned
Copy link
Description
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
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. - It makes python-ldap compatible with PEP 684 Per-Interpreter GIL and safe to use with multiple subinterpreters.
Required changes
- Port
PyTypeObject LDAP_Typeto heap type.- Replace static
PyTypeObject LDAP_TypewithPyType_SlotandPyType_Spec - Allocate object with
PyObject_GC_Newand free it withPyObject_GC_UnTrack/PyObject_GC_Del - Add GC protocol (traverse, clear) to track the heap reference to the type
- Initialize type with
PyType_FromSpec
- Replace static
- Create
_ldapC extension module with multi-phase initialization- Export module-level functions from
functions.candldapcontrol.c. This also gets rid ofLDAPadd_methodshack,LDAPinit_functions, andLDAPinit_control - Define
PyModuleDef_Slotto init type, constants, and pkginfo - Make
PyModuleDefglobal static - Initialize module with
PyModuleDef_Init
- Export module-level functions from
- Remove static globals
LDAP_Type,LDAPexception_class, anderrobjectsin favor of module state struct.- Define
LDAPModStateand add it toPyModuleDef - Add state pointer to
LDAPObject.PyType_GetModuleState()is not available in Python < 3.9 and became part of the stable ABI in 3.10. - Change all functions to get reference to type or exceptions from module state. This change is the largest diff and requires changes to several helper functions, especially error functions like
LDAPerror.
- Define
- Replace some macros with limited API functions, e.g.
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. - Build
_ldapextension module with limited API and stable ABI parameters.
encukou
Metadata
Metadata
Assignees
Labels
No labels