A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-March/147651.html below:

[Python-Dev] __del__ is not called after creating a new reference

[Python-Dev] __del__ is not called after creating a new referenceOleg Nesterov oleg at redhat.com
Tue Mar 21 14:22:23 EDT 2017
On 03/20, Nathaniel Smith wrote:
>
> Modern CPython, and all extant versions of PyPy and Jython, guarantee that
> __del__ is called at most once. MicroPython doesn't support user-defined
> __del__ methods.
>
> It's fine if the text wants to leave that open, but the current phrasing is
> pretty misleading IMO. I also read it as saying that __del__ would be
> called again if the object is collected again (which may or may not
> happen).

Yes, that is why I was confused. Just I could not believe nobody else noticed
this "bug" so I decided to check the sources and yes, the code looks very clear.

> But AFAICT there are actually zero implementations where this is
> true.

Probably this was mostly true until the commit 796564c2 ("Issue #18112: PEP
442 implementation (safe object finalization)."), python2 calls __del__ again.

> Probably worth a small edit :-)

Agreed. And it seems that not only me was confused,
http://doc.pypy.org/en/latest/cpython_differences.html says:

	There are a few extra implications from the difference in the GC. Most
	notably, if an object has a __del__, the __del__ is never called more
	than once in PyPy; but CPython will call the same __del__ several times
	if the object is resurrected and dies again.

Thanks to all!

Oleg.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4