On Mon, 2 Feb 2004 21:29:15 -0800, "Jey Kottalam" <ko******@cs.ucdavis.edu>
wrote:
Hi,
The Python 2.3 Language Reference cautions that __del__ is not guarnateed to
be invoked at
http://www.python.org/doc/current/re...n.html#l2h-175 . I am
writing a Python extension in C and I was wondering if the same precautions
apply to tp_dealloc, that is, is there a possibility that the tp_delloc for
my type may not be invoked?
Yes, there is no guarantee that all tp_deallocs will be called when the
interpreter exits. In CPython, the interpreter does try to clean up when it
exits by clearing out all the modules, which will generally cause most objects
to have their tp_dealloc called. However, if the object is in a refcount cycle,
there is no guarantee that the cycle will get collected.
Note also that, unlike a python __del__ method, a tp_dealloc method will not
keep the garbage collector from collecting cycles.
---
Greg Chapman