Greg Ewing wrote:
> 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);
That makes sense - I was trying to avoid allocations (my day-job habits
leaking through again), but this is Python after all, and avoiding a
single memory allocation per type is silly.
> --
> Greg
>
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com