[Python-Dev] Changing PyModuleDef.m_reload to m_slots
Stefan Behnel
stefan_ml at behnel.de
Sat Apr 18 07:58:28 CEST 2015
Petr Viktorin schrieb am 17.04.2015 um 15:52:
> As a background, the PyModuleDef structure [1] is currently:
>
> struct PyModuleDef{
> PyModuleDef_Base m_base;
> const char* m_name;
> const char* m_doc;
> Py_ssize_t m_size;
> PyMethodDef *m_methods;
> inquiry m_reload;
> traverseproc m_traverse;
> inquiry m_clear;
> freefunc m_free;
> };
>
> ... where the m_reload pointer is unused, and must be NULL.
> My proposal is to repurpose this pointer to hold an array of slots, in the
> style of PEP 384's PyType_Spec [2], which would allow adding extensions --
> both those needed for PEP 489 and future ones.
FWIW, I'm +1 on this. It replaces a struct field that risks staying unused
basically forever with an extensible interface that massively improves the
current extension module protocol and allows future extensions (including
getting back the pointer we replaced).
The alternative of essentially duplicating all sorts of things to
accommodate for a new metadata struct is way too cumbersome and ugly in
comparison.
Stefan
More information about the Python-Dev
mailing list