report at bugs
Aug 4, 2012, 12:24 PM
Post #3 of 13
Richard Oudkerk added the comment:
[issue15528] Better support for finalization with weakrefs
[In reply to]
> I don't quite understand the purpose of your suggestions. What can you do
> with it help, what you can not do with contextlib.ExitStack, atexit,
> __del__ method, weakref.WeakKeyDictionary or weakref.ref? I read the
> documentation, but the meaning eludes me.
finalize does not "compete" with contextlib.ExitStack, atexit and
weakref.WeakKeyDictionary. It only competes with __del__ and weakref
Points 1 and 2 in my first message are the main points. Also, read the
which also applies to weakref callbacks.
Other problems with __del__:
* Ref cycles which contain an object with a __del__ method are immortal
* __del__ methods can "ressurect" the object.
There was actually a proposal to remove or replace __del__ methods in
Python 3000. See the "Removing __del__" thread(s):
As for weakref callbacks, I think they are just too difficult to use correctly
unless you are very familiar with them.
Python tracker <report [at] bugs>
Python-bugs-list mailing list