[pypy-dev] RFC: draft idea for making for loops automatically close iterators
Armin Rigo
armin.rigo at gmail.com
Sat Oct 22 19:23:25 EDT 2016
Hi Steven,
On 22 October 2016 at 01:13, Steven D'Aprano <steve at pearwood.info> wrote:
> Saving lives? That's a bit of an exaggeration, isn't it?
>
> There is a big discussion going on over on the Python-Ideas mailing
> list, and exaggerated, over-the-top responses aren't going to help this
> proposal's case. Already people have said this issue is only a problem
> for PyPy, so it's PyPy's problem to fix.
Why did CPython add ResourceWarning when a file is not explicitly
closed in the first place? That's because relying on reference
counting to close files has been judged a bad programming practice by
python-dev. The reasons for this judgement are along the lines of
"because it breaks on every non-refcounted implementation". It's a
good move from PyPy's point of view, and it is something that we
implemented on PyPy2 too.
Now the present discussion is about a similar case. Based on past
experience, people are going to say first "it's not really important",
then "it works fine in CPython", and finally in a few years python-dev
is going to realize that it's maybe more important than what they
originally thought.
Nathaniel is trying to do the right thing from the start instead, so
deserves a +1. Now *how* to do it exactly is a bit unclear, and
largely involves language design questions (which pypy-dev is not the
best place to address).
A bientôt,
Armin.
More information about the pypy-dev
mailing list