Hello Oleg,

On Mon, 20 Mar 2017 18:28:29 +0100
Oleg Nesterov <o...@redhat.com> wrote:
> I started to learn python a few days ago and I am trying to understand what
> __del__() actually does. https://docs.python.org/3/reference/datamodel.html
> says:
> 
>       object.__del__(self)
>       ...
>       Note that it is possible (though not recommended!) for the __del__()
>       method to postpone destruction of the instance by creating a new
>       reference to it. It may then be called at a later time when this new
>       reference is deleted.

This sentence is not technically wrong, but it can easily be
misleading.  It says "it *may* then be called at a later time" and
probably it should say "it may or may not be called at a later time,
depending on the Python implementation you are using".

Indeed CPython, the reference implementation, only calls __del__ once
and doesn't call it again on resurrected objects.  It is an
implementation detail, though, and other implementations are free to
behave otherwise, as garbage collectors are delicate beasts, difficult
to tame.

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to