Python vs Java garbage collection?

Erik Max Francis max at alcyone.com
Mon Dec 23 19:21:35 EST 2002


Robert Oschler wrote:

> Wait a minute, didn't Martin just say in a previous post that you can
> rely
> on CPython to call __del__ when reference counts reach 0?  How could
> Python
> "forget" to decrement a reference count, even if an exception occurs
> in a
> finally block or anywhere else for that matter?

Peter was giving an example where the reference count _didn't_ go to
zero, but a naive programmer might not have noticed that.  It's yet
another reason why explicit reclaiming of external resources is a good
idea, even independently of this immediate vs. deferred finalization
issue; it leaves open the opportunity for bugs.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ I used to walk around / Like nothing could happen to me
\__/ TLC
    EmPy / http://www.alcyone.com/pyos/empy/
 A templating system for Python.



More information about the Python-list mailing list