[Python-Dev] Changing PyModuleDef.m_reload to m_slots
Nick Coghlan
ncoghlan at gmail.com
Sat Apr 25 06:34:34 CEST 2015
On 18 April 2015 at 15:58, Stefan Behnel <stefan_ml at behnel.de> wrote:
> 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.
Sorry for the delayed reply (post-PyCon travel), but +1 from me as
well for the reasons Stefan gives.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list