feat: implement PEP489 (multi-phase module init, heap-allocated types) for Python >= 3.11#204
feat: implement PEP489 (multi-phase module init, heap-allocated types) for Python >= 3.11#204
Conversation
Clarify / regularize static string initialization: it should happen at module intern time, not on-the-fly.
|
I tried running |
It names APIs which *were* added in Python 3.9, but we need others not available until 3.11.
… into tseaver-pep489
|
@davisagli |
- Remove 'tp_dealloc' / 'tp_clear' slots (there are no allocated members). - Use 'timestamp_type->tp_alloc' rather than 'PyObject_New'.
Creating instances of 'type' or 'tuple' via 'PyType_GenericNew' leaves them in states which trigger assertions in their 'tp_dealloc' slots. These assertions are normally silent, but trigger when running under a Python built using '--with-debug' or '--with-assertions'.
|
@davisagli The last four commits clear up the remaining issues: tests now pass without segfaults under both "normal" Python >= 3.11 and under a |
That struct is actually just a borrowed pointer to the struct held in the module state of the 'cPersistence' extension module. Visiting / clearing it from withing 'cPickleCache' is inappropriate, and may lead to segfaults during program exit.
|
@davisagli re c8b34ca: I backed out the |
davisagli
left a comment
There was a problem hiding this comment.
You mentioned that this will be disruptive. Should we bump the major version as part of merging this?
I'm not sure. Likely should try installing the wheel built from this branch into tox environments for the |
Older Python versions continue to use static type init and static classes, although static state has been moved into the module state unconditionally.
I realize these changes are likely to be disruptive, in particular, for
BTrees, which I plan to handle next.