On Wed, 1 Jan 2020 11:51:41 -0800 "Gregory P. Smith" <g...@krypto.org> wrote: > On Wed, Jan 1, 2020 at 6:40 AM Andrew Svetlov <andrew.svet...@gmail.com> > wrote: > > > __del__ is very useful not for interpreter shutdown but as a regular > > destructor in object's lifecycle. > > > > The reason we should warn people against ever implementing __del__ is that > people rarely actually understand object lifecycle. Its presence > guarantees delayed garbage collection and that its code will code execute > in a context way outside of normal control flow that all other methods are > invoked from.
For the latter (executes in an arbitrary context): agreed. For the former (guarantees delayed garbage collection): what do you mean? Regardless, +1 for pointing to `weakref.finalize` as a better alternative for things that may survive until interpreter shutdown. Most people don't know about this kind of detail, and it can bite hard when working on complex systems. Regards Antoine. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/3KP3YPMR2HX33QTBV7D5TBHIJBPL6FNW/ Code of Conduct: http://python.org/psf/codeofconduct/