[Python-Dev] Cycle collection enhancement idea

Antoine Pitrou solipsis at pitrou.net
Sun Jun 29 14:04:28 CEST 2008


eyal.lotem+pyutils <at> gmail.com <eyal.lotem <at> gmail.com> writes:
> This is exactly what my post tried to address.
> I assumed it was clear that module clearing is the wrong solution, and
> that it was also clear that due to the cycles I mentioned
> (global.__class__.__dict__['any_method'].func_globals['global'] is
> global), all globals that have a __del__ will not be collectible.
> Therefore, I proposed a solution to cycles with a __del__ in them.
> Only with this solution it is possible to replace module clearing with
> normal garbage collection.

A more generic solution would be to pass a special flag to the GC when it is
called as part of interpreter shutdown. This flag would instruct it to not put
aside objects with finalizers, but first call all their __del__ methods and then
collect them all at once regardless of whether they are part of a cycle or not.





More information about the Python-Dev mailing list