[Python-Dev] Linus on garbage collection (original) (raw)

Michael Foord fuzzyman at voidspace.org.uk
Fri May 6 19:04:53 CEST 2011


On 06/05/2011 17:32, Gregory P. Smith wrote:

On Fri, May 6, 2011 at 9:18 AM,<skip at pobox.com> wrote:

Antoine> Since we're sharing links, here's Matt Mackall's take: Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html

> From that note: 1: You can't have meaningful destructors, because when destruction happens is undefined. And going-out-of-scope destructors are extremely useful. Python is already a rather broken in this regard, so feel free to ignore this point. Python being "broken" in this regard is pretty much exactly why enter, exit and with as context managers were added to the language.

How does that help with cycles? Sure it makes cleaning up some resources easier, but not at all this case. Explicit destruction is of course always an alternative to the runtime doing it for you, but it doesn't help with (for example) reclaiming memory. For long running processes memory leaks due to unreclaimable cycles can be a problem with CPython.

That gives the ability to have the equivalent of well defined nested scopes that destroy something (exit) deterministically much as it is easy to do in C++ with some {}s and a ~destructor().

It is not broken, just different.

+1 QOTW ;-)

Michael

-gps


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk

-- http://www.voidspace.org.uk/

May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html



More information about the Python-Dev mailing list