[Pyrex] Subclassing a non-GC type

Stefan Behnel stefan_ml at behnel.de
Sat Jan 12 10:10:02 CET 2008


Hi Eric,

Eric Huss wrote:
>> BTW, shouldn't we in turn drop these two functions (and TPFLAGS_HAVE_GC) for
>> extension types that do not have Python object members? If this is the only
>> difference, I don't see why they should be there.
> 
> It looks like Greg was going to implement this, but didn't finish it.
> 
> We have a patched version of Pyrex that essentially does this.  In
> TypeSlots.py, there is a commented out bit to handle this (look for if
> scope.has_pyobject_attrs where it sets the HAVE_GC flag).  We uncommented
> that (and removed HAVE_GC from the default list), and it is working well
> for us.

That's good to know, thanks. I'll look into this.


> You should also change the tp_free slot define from a
> GCDependentSlot to EmptySlot (this is some 2.2 backwards compatibility
> issue which I believe Pyrex no longer supports).

The comment suggests that it's a work-around for older 2.2 versions. I don't
see any obligation to support anything but the newest version of an outdated
Python series.


> We didn't bother with
> removing the tp_traverse/tp_clear definitions since Python will
> essentially ignore them if HAVE_GC is not set.

Cython should still do that since pointing to the functions from the type
struct will keep them in the binary, which unnecessarily bloats the code. I'll
see if we can't just skip their generation.

Stefan



More information about the Pyrex mailing list