[Python-ideas] Why not break cycles with one __del__?

Tim Peters tim.peters at gmail.com
Mon Sep 13 19:25:54 CEST 2010

[Jim Jewett]
>> The last time I checked ...
>> single-__del__ cycles were already handled OK.

[Antoine Pitrou]
> They aren't: ...

Antoine's right, unless things have changed dramatically since last
time I was intimate with that code.  CPython's "cyclic garbage
detection" makes no attempt to analyze cycle structure.  It infers
that all trash it sees must be in cycles simply because the trash
hasn't already been collected by the regular refcount-based gc.  The
presence of __del__ on a trash object then disqualifies it from
further analysis, but there's no analysis of cycle structure

Of course it doesn't _have_ to be that way.  Nobody cared enough yet
to add a pile of new code to special-case cycles with a single

More information about the Python-ideas mailing list