[Python-Dev] Python Language Summit EuroPython 2010

Stefan Behnel stefan_ml at behnel.de
Fri Jul 23 07:19:40 CEST 2010


Maciej Fijalkowski, 22.07.2010 10:43:
> On Thu, Jul 22, 2010 at 9:51 AM, Brett Cannon wrote:
>> Basically the whole setting a module's globals to None was done before gc
>> came into the language. Now that it's there it seems that it might work to
>> simply let gc clean up the module itself. But this brings in the question of
>> how to order calling finalizers. It seemed the room had no specific answer
>> other than it might just have to be near random as figuring out a reasonable
>> order is hard.
>
> If you have a cycle, there is no other way than breaking it at random, right?

This is where reference counting is pretty handy. It allows users to 
deliberately increase the reference count of certain objects that they want 
to stay alive longer than their own object, so that the GC cannot just 
collect them before they call the opposite decref in your finaliser. This 
obviously requires taking care that the objects you manipulate here cannot 
create reference-cycles themselves, but given that, it helped me fix a lot 
of hard to track down crashes in lxml.

Stefan



More information about the Python-Dev mailing list