does python have useless destructors?

Peter Hansen peter at engcorp.com
Fri Jun 11 16:19:22 EDT 2004


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.

-Peter



More information about the Python-list mailing list