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

2021-05-20 Thread STINNER Victor
STINNER Victor added the comment: See also https://discuss.python.org/t/define-module-constants-in-pymoduledef/5749 -- nosy: +vstinner ___ Python tracker ___

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

2021-05-20 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Yes. It's becoming hard to implement both static and heap types using one struct member. Since this is all about implementing a helping hand when it comes to types I think two different members one for static and another one for heap would be fine. And if s

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

2021-05-20 Thread Christian Heimes
Christian Heimes added the comment: I suggest you try to implement your proposal first before you post it. (spoilers: you will notice that it doesn't work for non-trivial heap types.) -- nosy: +christian.heimes ___ Python tracker

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

2021-05-20 Thread Shreyan Avigyan
Shreyan Avigyan 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

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

2021-05-20 Thread Erlend E. Aasland
Erlend E. Aasland added the comment: How will you differentiate which types should be added to the module dict and which not to add. How will you map the instantiated type objects to the respective module state members? -- ___ Python tracker

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

2021-05-20 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: I'm not sure if bpo-42376 is same as this one. Yes the basic idea to provide abstraction and make it easy for the users to add type is same but the approaches suggested are completely different. I propose a new structure member in PyModuleDef be added where

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

2021-05-20 Thread Erlend E. Aasland
Erlend E. Aasland added the comment: See also bpo-42376 -- nosy: +erlendaasland ___ Python tracker ___ ___ Python-bugs-list mailing

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

2021-05-19 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Yes and it wouldn't be a problem. If struct member is 0 or NULL then use default behavior. If not then apply PyModule_AddType or PyModule_AddObject on all of those. Then after finishing set slot to NULL again since we don't want to add a type more than once

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

2021-05-19 Thread Petr Viktorin
Petr Viktorin added the comment: First off, note that you can use PyModule_AddType rather than PyModule_AddObject to avoid repeating the name. Adding this *correctly* will be somewhat involved: slots take function pointers, not data pointers which are incompatible according to standard C. Th

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

2021-05-19 Thread Shreyan Avigyan
Change by Shreyan Avigyan : -- title: [c-api] Introduce a new slot in PyModuleDef to hold the classes -> [C API] Introduce a new slot in PyModuleDef to hold the classes ___ Python tracker ___

[issue44099] [c-api] Introduce a new slot in PyModuleDef to hold the classes

2021-05-18 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: A friendly ping -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue44099] [c-api] Introduce a new slot in PyModuleDef to hold the classes

2021-05-11 Thread Shreyan Avigyan
Change by Shreyan Avigyan : -- title: Introduce a new slot in PyModuleDef to hold the classes -> [c-api] Introduce a new slot in PyModuleDef to hold the classes ___ Python tracker ___