[Python-Dev] C new-style classes and GC (original) (raw)
Guido van Rossum guido@python.org
Fri, 16 May 2003 13:37:21 -0400
- Previous message: [Python-Dev] Re: C new-style classes and GC
- Next message: [Python-Dev] C new-style classes and GC
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
But calling tp_free is more correct. This allows a subclass to change the memory allocation policy. (This is also important if a base class is not collectible but a subclass is -- then it's essential that the base class dealloc handler calls tp_free.)
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Re: C new-style classes and GC
- Next message: [Python-Dev] C new-style classes and GC
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]