[Python-ideas] Python 3000 TIOBE -3%

Tim Delaney timothy.c.delaney at gmail.com
Fri Feb 10 10:32:14 CET 2012


On 10 February 2012 20:16, Dirkjan Ochtman <dirkjan at ochtman.nl> wrote:

> There are some simple patterns that are great with refcounting and not
> so great with garbage collection. We encountered some of these with
> Mercurial. IIRC, the basic example is just
>
> open('foo').read()
>
> With refcounting, the file will be closed soon. With garbage
> collection, it won't. Being able to rely on cleanup per frame/function
> call is pretty useful.


This is the #1 anti-pattern that shouldn't be encouraged. Using this idiom
is just going to cause problems (mysterious exceptions while trying to open
files due to running out of file handles for the process) for anyone trying
to port your code to other implementations of Python.

If you read PEP 343 (and the various discussions around that time) it's
clear that the above anti-pattern is one of the major driving forces for
the introduction of the 'with' statement.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120210/29233e6e/attachment.html>


More information about the Python-ideas mailing list