[Pyrex] Subclassing a non-GC type

Lenard Lindstrom len-l at telus.net
Tue Jan 29 08:57:57 CET 2008


Greg Ewing wrote:
> Lenard Lindstrom wrote:
>
>   
>> Looking at the inherit_special function in typeobject.c I see that 
>> PyType_Ready promotes tp_traverse,  tp_clear and HAVE_GC.
>>     
>
> In that case, it should be sufficient to just omit tp_traverse,
> tp_clear and HAVE_GC on any type that doesn't have Python
> valued C attributes.
>
> I think the reason I didn't do that initially was that
> PyType_Ready didn't do all the right things back then, and
> not fully understanding what was going on, I didn't want
> to be too clever.
>
>   
PyType_Ready does plenty of clever things like fill tp slots when
special methods are found and add special methods when tp slots are
filled. It handles all the inheritance requirements to make an extension
type look like a new-style class.

-- 
Lenard Lindstrom
<len-l at telus.net>





More information about the Pyrex mailing list