Showing content from http://mail.python.org/pipermail/python-dev/attachments/20170320/a04c4570/attachment.html below:
<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Mar 20, 2017 1:26 PM, "Antoine Pitrou" <<a href="mailto:solipsis@pitrou.net">solipsis@pitrou.net</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hello Oleg,<br>
<div class="quoted-text"><br>
On Mon, 20 Mar 2017 18:28:29 +0100<br>
Oleg Nesterov <<a href="mailto:oleg@redhat.com">oleg@redhat.com</a>> wrote:<br>
> I started to learn python a few days ago and I am trying to understand what<br>
> __del__() actually does. <a href="https://docs.python.org/3/reference/datamodel.html" rel="noreferrer" target="_blank">https://docs.python.org/3/<wbr>reference/datamodel.html</a><br>
> says:<br>
><br>
>Â Â Â Â object.__del__(self)<br>
>Â Â Â Â ...<br>
>Â Â Â Â Note that it is possible (though not recommended!) for the __del__()<br>
>Â Â Â Â method to postpone destruction of the instance by creating a new<br>
>Â Â Â Â reference to it. It may then be called at a later time when this new<br>
>Â Â Â Â reference is deleted.<br>
<br>
</div>This sentence is not technically wrong, but it can easily be<br>
misleading. It says "it *may* then be called at a later time" and<br>
probably it should say "it may or may not be called at a later time,<br>
depending on the Python implementation you are using".<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">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). But AFAICT there are actually zero implementations where this is true. Probably worth a small edit :-)</div><div dir="auto"><br></div><div dir="auto">-n</div></div>
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