On 4/8/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
Brad Clements wrote:
>
> so, maybe offer "close" methods on objects that hold references to other
> resources... and have __del__ call those close methods, and make sure
> that multiple close calls are ok.. I think thats the most reasonable
> thing to do without going crazy, but still leaves open the opportunity
> for explicit resource release when needed.
>
> I think this is a low priority issue.. maybe even just an advisory to
> keep in my when developing new code. I don't think it's worth acting on
> now to the detriment of more important work.
>
> thanks
>

Ok, im glad youre cool with __del__() for cPython usage....I think its
behavior is quite reliable sans circular references and was one of the
things I liked about Python compared to Java.  I think the issue is
somewhat critical because this is the kind of thing that has an impact on
the API, some of the internal constructs to the SQLEngine which I am in
the middle of reworking, and is also something to keep in mind as we come
up with new usage patterns...."dont get too comfortable with the automatic
closing of resources".

Yeah, if you're talking about Python-the-standard as opposed to CPython then __del__ is basically broken for this purpose.  (I'm having trouble thinking of a purpose for which it _wouldn't_ be broken...)  IronPython is probably as bad as Jython here.

The good news is that the "with" statement in 2.5 will address most of the __del__ use cases.  The bad news is, we can't exactly require that yet. :)

(And heaven only knows when Jython will get a 2.3 release out, let alone 2.5...)

--
Jonathan Ellis
http://spyced.blogspot.com

Reply via email to