[Python-ideas] Why not break cycles with one del? (original) (raw)

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 regardless.

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 del.



More information about the Python-ideas mailing list