On Sun, 11 Aug 2013 07:04:40 -0400 Nick Coghlan <ncogh...@gmail.com> wrote: > On 11 August 2013 06:33, Antoine Pitrou <solip...@pitrou.net> wrote: > > So code can be written like: > > > > PyObject *dialects = PyState_GetModuleAttr( > > &_csvmodule, "dialects", &PyDict_Type); > > if (dialects == NULL) > > return NULL; > > This sounds like a good near term solution to me. > > Longer term, I think there may be value in providing a richer > extension module initialisation API that lets extension modules be > represented as module *subclasses* in sys.modules, since that would > get us to a position where it is possible to have *multiple* instances > of an extension module in the *same* subinterpreter by holding on to > external references after removing them from sys.modules (which is > what we do in the test suite for pure Python modules).
Either that, or add a "struct PyMemberDef *m_members" field to PyModuleDef, to enable looking up stuff in the m_state using regular attribute lookup. Unfortunately, doing so would probably break the ABI. Also, allowing for module subclasses is probably more flexible in the long term. We just need to devise a convenience API for that (perhaps by allowing to create both the subclass *and* instantiate it in a single call). > However, that's dependent on the ModuleSpec idea we're > currently thrashing out on import-sig (and should be able to bring to > python-dev soon), and I think getting that integrated at all will be > ambitious enough for 3.4 - using it to improve extension module > handling would then be a project for 3.5. Sounds reasonable. Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com