Re: PEP 489: Redesigning extension module loading
Stefan Behnel <[email protected]> Sun, 26 Apr 2015 10:31:58 +0200
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <[email protected]> |
Petr Viktorin schrieb am 17.04.2015 um 12:33: > On 04/17/2015 08:51 AM, Stefan Behnel wrote: >> Petr Viktorin schrieb am 16.04.2015 um 13:05: >>> A wart I added is "singleton modules", necessary for >>> "PyState_FindModule"-like functionality. I wouldn't mind not including >>> this, but it would mean the new API can't replace all use cases of the >>> old PyInit_. >>> >>> Singleton Modules >>> ----------------- >>> >>> Modules defined by PyModuleDef may be registered with PyState_AddModule, >>> and later retrieved with PyState_FindModule. >>> >>> Under the new API, there is no one-to-one mapping between PyModuleSpec >>> and the module created from it. >>> In particular, multiple modules may be loaded from the same description. >> >> Is that because a single shared library (which is what the module spec >> refers to, right?) can contain multiple modules? Or are you referring to >> something else here? > > By using Loader.create_module/Loader.exec_module directly, you can load an > extension module without adding it to sys.modules. You can do this as many > times as you like, and you always get a new, independent module object. Should we even allow that for extension modules, as long as there is no reloading support? I guess subinterpreters would also have a say in this, right? Stefan