[Python-ideas] Why not break cycles with one __del__?
Antoine Pitrou
solipsis at pitrou.net
Mon Sep 13 19:05:49 CEST 2010
On Mon, 13 Sep 2010 12:16:36 -0400
Jim Jewett <jimjjewett at gmail.com> wrote:
>
> The last time I checked, there were proposals toeither add a
> __close__ or weaken __del__ to handle multi-__del__ cycles -- but
> single-__del__ cycles were already handled OK.
They aren't:
>>> class C(list):
... def __del__(self): pass
...
>>> c = C()
>>> c.append(c)
>>> del c
>>> import gc
>>> gc.collect()
1
>>> gc.garbage
[[[...]]]
>>> type(gc.garbage[0])
<class '__main__.C'>
More information about the Python-ideas
mailing list