[Python-Dev] C new-style classes and GC (original) (raw)
Jeremy Hylton jeremy@zope.com
16 May 2003 13:35:33 -0400
- Previous message: [Python-Dev] C new-style classes and GC
- Next message: [Python-Dev] Re: C new-style classes and GC
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 2003-05-16 at 13:08, Jim Fulton wrote:
If you write types the New Way, there are no PyObjectNew calls and no need to call PyObjectGCTrack.
I don't follow. There are plenty of types that are garbage collectable that also use PyObject_GC_New. One example is PyDict_New(). If something is widespread in the Python source tree (a common source of example code for programmers), it ought to be documented.
> It's not clear to me what the one right way to implement a tpdealloc > slot is. I've seen two common patterns in the Python source: call > obj->obtype->tpfree or call PyObjectGCDel. The type object > initializes tpfree to PyObjectGCDel, so in most cases the two > spellings are equivalent. Calling PyObjectGCDel feels more > straightforward to me.
You need to call obj->obtype->tpfree to support subclassing. I suggest that every new type should call obj->obtype->tpfree as a matter of course.
If the type is going to support subclassing.
Jeremy
- Previous message: [Python-Dev] C new-style classes and GC
- Next message: [Python-Dev] Re: C new-style classes and GC
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]