Fredrik Lundh wrote: > Martin v. Löwis wrote: > >> Of course, if everybody would always recompile all extension modules >> for a new Python feature release, those flags weren't necessary. > > a dynamic registration approach would be even better, with a single entry > point > used to register all methods and hooks your C extension has implemented, and > code on the other side that builds a properly initialized type descriptor > from that > set, using fallback functions and error stubs where needed. > > e.g. the impossible-to-write-from-scratch NoddyType struct initialization in > > http://docs.python.org/ext/node24.html > > would collapse to > > static PyTypeObject NoddyType;
Wouldn't that have to be a pointer to allow the Python runtime complete control of the structure size without recompiling the extension?: static PyTypeObject *NoddyType; NoddyType = PyType_Alloc("noddy.Noddy"); if (!NoddyType) return; PyType_Register(NoddyType, PY_TP_DEALLOC, Noddy_dealloc); PyType_Register(NoddyType, PY_TP_DOC, "Noddy objects"); PyType_Register(NoddyType, PY_TP_TRAVERSE, Noddy_traverse); PyType_Register(NoddyType, PY_TP_CLEAR, Noddy_clear); PyType_Register(NoddyType, PY_TP_METHODS, Noddy_methods); PyType_Register(NoddyType, PY_TP_MEMBERS, Noddy_members); PyType_Register(NoddyType, PY_TP_INIT, Noddy_init); PyType_Register(NoddyType, PY_TP_NEW, Noddy_new); if (PyType_Ready(NoddyType) < 0) return; Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ 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