By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,907 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,907 IT Pros & Developers. It's quick & easy.

__del__ warnings apply to tp_dealloc?

P: n/a
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?

Thanks in advance,
Jey Kottalam
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.