Order of constructor/destructor invocation

Paul Rubin phr-n2002a at nightsong.com
Tue Mar 5 00:51:33 EST 2002


"Reginald B. Charney" <news at charneyday.com> writes:
> In Python, are destructors defined to be invoked in reverse order of
> constructors? 

Huh?  No, of course not.  The destructor is called when the last
reference goes away.  That can happen in any order.

> Basically, I need to know if the order of destruction is guaranteed to be
> the reverse of construction when reference counts on the objects are the
> same (e.g., 1 on this case). Without this guarantee, I don't understand how
> Python can effectively use destructors - it falls into the same hole as
> Java. For me, this is a show-stopper.

When the ref count is 1, the object is still alive.



More information about the Python-list mailing list