This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sbt
Recipients sbt, serhiy.storchaka
Date 2012-08-04.19:24:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344108271.0.0.326102479203.issue15528@psf.upfronthosting.co.za>
In-reply-to
Content
> 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
callbacks.

Points 1 and 2 in my first message are the main points.  Also, read the
warning at

  http://docs.python.org/py3k/reference/datamodel.html#object.__del__

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):

  http://mail.python.org/pipermail/python-3000/2006-September/thread.html#3797

As for weakref callbacks, I think they are just too difficult to use correctly
unless you are very familiar with them.
History
Date User Action Args
2012-08-04 19:24:31sbtsetrecipients: + sbt, serhiy.storchaka
2012-08-04 19:24:31sbtsetmessageid: <1344108271.0.0.326102479203.issue15528@psf.upfronthosting.co.za>
2012-08-04 19:24:30sbtlinkissue15528 messages
2012-08-04 19:24:29sbtcreate