[Python-Dev] PEP 442: Safe object finalization (original) (raw)

Antoine Pitrou solipsis at pitrou.net
Sat May 18 15:02:52 CEST 2013


On Sat, 18 May 2013 22:51:35 +1000 Nick Coghlan <ncoghlan at gmail.com> wrote:

On Sat, May 18, 2013 at 9:46 PM, Antoine Pitrou <solipsis at pitrou.net> wrote: > On Sat, 18 May 2013 21:05:48 +1000 > Nick Coghlan <ncoghlan at gmail.com> wrote: >> On Sat, May 18, 2013 at 6:59 PM, Antoine Pitrou <solipsis at pitrou.net> wrote: >> > Resurrection >> > The process by which a finalizer creates a new reference to an >> > object in a CI. This can happen as a quirky but supported >> > side-effect of _del_ methods. >> >> I really like the PEP overall, but could we at least get the option to >> have cases of object resurrection spit out a warning? And a clear >> rationale for not turning on such a warning by default? > > Where would you put the option? > As for the rationale, it's simply compatibility: resurrection works > without warnings right now :)

Command line, probably. However, you're right that's something we can consider later - for the PEP it's enough that it still works, and we just avoid calling the del method a second time.

Actually, the del method is called again on the next destruction attempt - as mentioned in the PEP:

« Following this scheme, an object's finalizer is always called exactly once. The only exception is if an object is resurrected: the finalizer will be called again later. »

I could change it to only call del ever once, it just sounded more logical to call it each time destruction is attempted.

(this is in contrast to weakrefs, though, which are cleared once and for all)

Regards

Antoine.



More information about the Python-Dev mailing list