Messing with the GC
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Jan 19 11:34:53 EST 2013
On Sat, 19 Jan 2013 16:24:37 +0000, Steven D'Aprano wrote:
> On Sat, 19 Jan 2013 14:47:16 +0000, Jens Thoms Toerring wrote:
>
>> Ok, the destrucor for the first instance of the X class is called only
>> after printing out "After", so the GC didn't delete the object before.
>> But then there are obviously no calls of the destructors of neither the
>> second instance of the X class nor of the Y class instance. Shouldn't
>> they be invoked before the program ends?
>
> You should avoid __del__ destructors whenever not absolutely necessary.
And here is another opinion: you should avoid cycles, rather the __del__.
http://eli.thegreenplace.net/2009/06/12/safely-using-destructors-in-python/
--
Steven
More information about the Python-list
mailing list