[issue44099] [C API] Introduce a new slot in PyModuleDef to hold the classes

Shreyan Avigyan report at bugs.python.org
Thu May 20 08:51:35 EDT 2021


Shreyan Avigyan <shreyan.avigyan at gmail.com> added the comment:

In PyModule_Create -> PyModule_Create2 -> SomeFunc... it would loop through the array of object addresses and call PyModule_AddType on each and every one of them. This will not change behavior or control flow only implement a handy way. This I've found very distrubing,

PyModule_AddType(&Example1);
PyModule_AddType(&Example2);
PyModule_AddType(&Example3);


The proposed way will be

PyModuleDef examplemodule = {
    ...
    .types = {Example1, Example2, Example3};
    ...
}

Now just calling PyModule_Create (not PyModule_Init or any other initialization function) would add those types automatically.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44099>
_______________________________________


More information about the Python-bugs-list mailing list