does python have useless destructors?

Humpty Dumpty oliver.schoenborn at utoronto.ca
Sat Jun 12 00:21:29 CEST 2004


"Peter Hansen" <peter at engcorp.com> wrote in message
news:PfednezhqfRRjlfdRVn-vg at powergate.ca...
> Humpdydum wrote:
>
> > The object actually *does* know when to dispose of itself: when its ref
> > count goes to zero. Naturally, if you have an object that wraps a
resource
> > that needs cleanup, it goes without saying that that object shouldnt' be
> > referenced all over the place; rather, there should be only one ref to
it,
> > in the function that instantiates it, and that's all. Then when the
function
> > exits, the object sees ref cnt=0 and knows to cleanup after itself.
>
> This is an unrealistic requirement.  It implies that all access
> to some resource must occur within a single function, which is
> too great a limitation for many real applications.

As long as only one ref left on function exit, there is no limitation of
access.

Oliver





More information about the Python-list mailing list