[Python-Dev] Garbage collecting closures

Paul Prescod paul@prescod.net
Mon, 14 Apr 2003 12:43:58 -0700


> 
> Finalizers seem useful in general, but I would still worry about any
> specific program that managed critical resources using finalizers.
> 
> Jeremy

Finalizer behaviour is implementation specific. Fair enough.

Therefore, portable programs don't use finalizers. Okay, fine. Not all 
Python programs are designed to be portable. Finalizers tend to be used 
to deal with non-portable resources (COM objects, database handles) anyhow.

This suggests to me that each implementation should document in detail 
how finalizers work in that implementation. After all, if you can't 
depend on them to work predictably even within a single implementation, 
what is their value at all? A totally unpredictable feature is of little 
more value than no feature at all.

I propose to collect the various garbage collection special cases we've 
described in this discussion and write a tutorial for the CPython 
documentation. Does anyone know of any more special cases? Probably any 
library or language feature that can create non-obvious circular 
references should be listed.

  Paul Prescod