Generator inside a class prevent __del__ ??
Rob Nikander
rnikaREMOVEnder at adelphia.net
Tue Apr 20 23:19:38 EDT 2004
Mark Day wrote:
> still isn't called. There must still be a reference to the object. My
> guess is that the generator (directly or indirectly) is referencing the
> object, creating a self referential loop.
>
Python has a garbage collector that will try to find these objects with
cyclic references.
from test import *
>>> a = toto()
init
>>> a = None
>>> import gc
>>> gc.garbage
[]
>>> gc.collect()
4
>>> gc.garbage
[<test.toto instance at 0x81cb78c>]
>>>
I checked out the documentation for that gc.garbage list and it says
that the collector can't free objects in cycles if the cyles have
objects that have __del__ methods. So it puts them in this list.
I wonder what other garbage collectors do in this situation? Anyone
know? Java?
Rob
More information about the Python-list
mailing list