On Mon, Aug 16, 2004 at 09:49:00AM -0500, Jason Sibre wrote: > __del__() method.) I guess the appropriate use of __del__(), then, is to use > it for clearing out in-memory resources that can be safely forgotten about in > the case of an interpretter shutdown. All resources that exist (or have > components which exist) outside of the interpretter should be handled > explicitly, ideally in a finally block, or the like. I believe, perhaps mistakenly, that __del__ was orignally intended only to help garbage collection out by breaking up cycles - this back in the day when Python's GC was nothing but the core reference-counting facility. So the problem is that it sounds as though it's very like, say, C++ destructors, which folks have learned to exploit in order to work around more egregious shortcomings of that language, such as its lack of garbage collection. Which is ironic, because it was Stroustrup himself who, in a long-ago article in comp.lang.c++, explained the essential problem with finalizers in a GC'd setting. In essence, GC is a way of simulating a larger than available memory (1) - in the limit, simulating an infinite space. Now, if one actually had an effectively infinite space, how would GC work in that environment? It would do nothing, of course, since the memory space already appears infinite, and doing any work to reclaim dead space would serve no purpose. So in the limit finalizers should never be called by the GC system... Except I'm sure the original statement was more compelling. But as far as I can tell, this predates Google's archives (or perhaps falls into a gap), and whatever copies I once had seem to be gone, leaving only my ever more fallible memory. :-/ (1) in a virtual memory environment this is not untrue, but nitpickers might prefer to think of it as making more efficent use of the available [virtual] memory space - the same conclusion follow. -- One lesson I've learned from my years as Linux's hood ornament is that there's something worse: some folks can't be content to just take things too seriously on their own. They're not happy unless they can convince others to go along with their obsession. -- Linus