[Pyrex] __del__ not called on some objects

len-l at telus.net len-l at telus.net
Sat Aug 27 22:21:17 CEST 2005


On 26 Aug 2005 at 1:00, John (J5) Palmieri wrote:

You want a __dealloc__ method for your cdef extension type. It is described in the 
special methods section of the documentation. It is the destructor counterpart of the 
cdef __new__, which should not be confused with the new-style class __new__.

Lenard Lindstrom
<len-l at telus.net>

> You can find my simple test case at
> http://people.redhat.com/johnp/files/pyrex_bug.tar.gz
> 
> tar xvfzp pyrex_bug.tar.gz
> cd pyrex_bug
> make
> python test.py
> 
> It will show two objects being created with only one calling the __del__
> handler.  The failing object is declared as a cdef which is what causes
> it to not call __del__ however simply deriving from it with a regular
> class does call Test's __del__ method on object destruction.
> 
> It occurred to me that this might be intentional (however confusing)
> since the cdef object it technically a c structure so I am not sure if
> it is subject to the same life cycle as a python object though I don't
> know why not since it acts just like one for the most part.
> 
> Anyway, there it is.
> 




More information about the Pyrex mailing list