does python have useless destructors?

Donn Cave donn at u.washington.edu
Thu Jun 17 14:51:34 EDT 2004


In article <m3hdtam7z0.fsf at pc150.maths.bris.ac.uk>,
 Michael Hudson <mwh at python.net> wrote:

> Donn Cave <donn at u.washington.edu> writes:
> 
> > In article <m3k6y6o8cd.fsf at pc150.maths.bris.ac.uk>,
> >  Michael Hudson <mwh at python.net> wrote:
> > > Donn Cave <donn at u.washington.edu> writes:
> > > > In article <m3fz8xozi1.fsf at pc150.maths.bris.ac.uk>,
> > > >  Michael Hudson <mwh at python.net> wrote:
> > > > > I would urge everyone participating in this thread to read PEP 310,
> > > > > the email conversation linked therein and (optional) *understand* it.
> > > > 
> > > > It seems to be superficially similar to finalization, 
> > > 
> > > OK, I've found this thread pretty hard to follow.  What is
> > > "finalization" in context?
> > 
> > Operational definition would be `call __del__ or its C equivalent',
> > at the effective end of the object's lifetime.
> 
> OK.  I claim you can't really have that, and that you don't really
> need it anyway.  The idea behind PEP 310 is to acheive the ends of
> RAII in C++ by different means.
> 
> What else do you want to use __del__ methods for?

That would be my question.  That's what __del__ methods _are_
used for.  C Python users _do_ really have that, it just takes
more care than we like if it needs to be 100% reliable.

Maybe I don't need it, maybe 310 gives me RAII and that's what
I really need.  I don't know, but again, 310 doesn't give me
anything of consequence in terms of software architecture.
Anything you can write with it, you can write without it by
simple substitution of try/finally.  That's not true of the
finalization that I have now in C Python, there's no effective
substitute for that.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list