[Python-3000] Removing __del__

Ron Adam rrr at ronadam.com
Tue Sep 26 17:32:27 CEST 2006


This was bit too brief I think...

Ron Adam wrote:

> How about...?  (This isn't an area I'm real familiar with.)
> 
> 
> Replace __del__ with:
> 
>     a __final__ method and a __finalized__ flag.  (or other equivalent names)

The __final__ method would need to be explicitly called, and the __finalized__ 
flag could be set either by the interpreter or the __final__ method when 
__final__ is called.  __final__ would never be called implicitly by the interpreter.

>     Insist on explicit finalizing by raising an exception if an objects
>     __finalize__ flag is still False when it looses it's last reference.
> 
> 
> Would this be difficult to do in a timely way so the traceback is meaningful?
> 
> Would this avoid the problems being discussed with both __del__ and weak refs?
> 
> 
>     Ron

Maybe just adding only an optional __finalized__ flag, that when False forces an 
exception if an object looses it's references, might be enough.

I think....

It's not the actual closing/finishing/etc... that is the problem, it's the 
detecting when closing/finishing/etc... is not done that is the problem.

Cheers,
    Ron











More information about the Python-3000 mailing list