[Python-Dev] Linus on garbage collection

Greg Ewing greg.ewing at canterbury.ac.nz
Sat May 7 01:43:16 CEST 2011


Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html
> 
>>From that note:
> 
>     1: You can't have meaningful destructors, because when destruction
>     happens is undefined. And going-out-of-scope destructors are extremely
>     useful. Python is already a rather broken in this regard, so feel free
>     to ignore this point.

It's only broken if you regard RAII as the One True Way to
implement scoped resource management. Python has other approaches
to that, such as the with-statement.

Also, you *can* have destructors that work for objects in cycles,
as long as you don't insist on the destructor having access to
the object that's being destroyed. Weakref callbacks provide a
way of implementing this in CPython.

-- 
Greg


More information about the Python-Dev mailing list