Am 11.12.2019 11:01 schrieb Greg Ewing:
On 11/12/19 7:47 am, R.Wieser wrote:
what happens when the reference becomes zero: is the __del__
method called directly (as I find logical), or is it only called when
the
garbage collector actually removes the instance from memory (which
Chris
thinks what happens) ?
In CPython, these are the same thing. As soon as the reference
count becomes zero, the __del__ method is called
Yes
*and* the object is removed from memory.
Not necessarily. Let's be more precise: The resources used by the object
are handed back to memory management (marked as free for re-use).
In a Python implementation that doesn't use reference counts,
using "del" on the last reference to an object probably isn't
going to do anything to the object.
It does exactly the same thing: It tells the memory management subsystem
that the instance's resources may be re-used.
--
https://mail.python.org/mailman/listinfo/python-list