[Python-Dev] Cycle collection enhancement idea (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Sun Jun 29 20:00:49 CEST 2008


As I explained above, it is part of a cycle: """including the class objects themselves: class->dict->function->funcglobals""".

Ah, right. I must have missed that explanation.

I know. I assumed Python does not rely on cyclic garbage collectioin for shutdown, because it wouldn't work, as all globals that have any instance method will be part of a cycle, and any of them which have a del will not be collected.

No. The mechanism for cleaning modules at shutdown time predates cyclic GC, and was not removed because "it wouldn't work".

This specific issue certainly contributes to the fact that it doesn't work, but there might be other problems as well (such as extension modules holding onto objects participating in cycles).

I mentioned this workaround. What I propose is not a workaround but a solution. You wouldn't need to clean up module globals ad-hoc'ishly, because the cyclic collection would collect your object, even with its del.

I don't think it solves the problem. You seem to be assuming that any such cycle will contain only a single global object with an del. However, as modules refer to each other, I very much doubt that is the case.

Please read my entire mail before replying to it. Thanks!

I really, really tried. I read it three times before replying.

However, I found it really, really difficult to follow your writing, as it was mixing problem statement and solution, so that I couldn't tell what paragraph was about what. English is not my native language, complicating communication further. Please accept my apologies.

Regards, Martin



More information about the Python-Dev mailing list