RFC: Proposal: Deterministic Object Destruction
Chris Angelico
rosuav at gmail.com
Wed Feb 28 18:01:42 EST 2018
On Thu, Mar 1, 2018 at 9:51 AM, <ooomzay at gmail.com> wrote:
> Specification
> =============
>
> When the last reference to an object goes out of scope the intepreter must synchronously, in the thread that releases the last reference, invoke the object's __del__() method and then free the memory occupied by that object.
>
If it were that simple, why do you think it isn't currently mandated?
Here's one example: reference cycles. When do they get detected?
Taking a really simple situation:
class Foo:
def __init__(self):
self.self = self
print("Creating a Foo")
def __del__(self):
print("Disposing of a Foo")
foo = Foo()
foo = 1
When do you expect __del__ to be called? How do you implement this
efficiently and reliably?
ChrisA
More information about the Python-list
mailing list