[Python-3000] A better way to initialize PyTypeObject
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Nov 28 11:42:04 CET 2006
Talin wrote:
> What you end up with is code that looks like this:
>
> PyTypeObject myType = {
> PyObject_HEAD_INIT(NULL)
> 0,
> "myType",
> sizeof(myInstance)
> }
>
> void init() {
> if (PyType_ReadyInit( &myType, myTypeMethods, myTypeData ) < 0)
> return;
> }
If you're going that far, why not go a step further and do
away with the statically-declared type object altogether?
PyTypeObject *myType;
myType = PyType_Create(sizeof(myInstance), myTypeMethods, myTypeData);
--
Greg
More information about the Python-3000
mailing list