CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)

Skip Montanaro skip at pobox.com
Fri Apr 26 20:22:55 EDT 2013


> Whenever the GC finds a cycle that is unreferenced but uncollectable,
> it stores those objects in the list gc.garbage.  At that point, if the
> user wishes to clean up those cycles, it is up to them to delve into
> gc.garbage, untangle the objects contained within, break the cycles,
> and remove them from the list so that they can be freed by the ref
> counter.

I wonder if it would be useful to provide a gc.garbagehook analogous
to sys.excepthook?
Users could assign a function of their choice to much the cyclic
garbage periodically.

Just a thought, flying out of my fingers before my brain could stop it...

Skip



More information about the Python-list mailing list