News for hackers. Stuff that matters.
Re:C++ the Good Parts (2014) by Nullabillity on Thursday October 01, 2020 @08:52AM (#24650279)
> Not true. They run when the object is deallocated. In CPython if the object is not involved in or referenced from a cycle, that’s as soon as it goes out of scope: the ref count goes to 0 and the object gets deallocated.

That's a CPython implementation detail, not a guarantee that you can rely on.

For example, both PyPy[0] and Jython use tracing GCs where this is not true.

[0]: https://doc.pypy.org/en/latest/cpython_differences.html

Re:C++ the Good Parts (2014) by masklinn on Thursday October 01, 2020 @05:10PM (#24656171)
> That's a CPython implementation detail

Which would be why I specifically wrote « in CPython ».

And it still makes the original assertion completely incorrect. Python destructors do not run « down the road, during the next GC cycle ». They may, in certain cases or implementations.

Re:C++ the Good Parts (2014) by Nullabillity on Thursday October 01, 2020 @05:45PM (#24656460)
Once again,

> implementation detail

There is no guarantee that even CPython will keep the current behaviour. Ultimately, the promise you're given is that __del__ might be invoked by the system some point between "the object has no live references" and "never".

The original assertion gives a much closer intuition than your description of the current behaviour.