[pypy-dev] RFC: draft idea for making for loops automatically close iterators

Steven D'Aprano steve at pearwood.info
Sun Oct 23 12:04:24 EDT 2016


On Sun, Oct 23, 2016 at 01:23:25AM +0200, Armin Rigo wrote:
> 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.


You are probably correct. On the Python-Ideas list, I've changed from 
mild opposition to mild support. I don't think it will be as disruptive 
as some people fear, and I think it probably will of benefit. But it 
would be nice to have some good, concrete examples of how it will help, 
rather than exaggerated claims of everyone's code being broken and 
saving lives. (I'm sure Hubo didn't *literally* mean people die from 
this, but still, it is hard to take people seriously when they 
exaggerate in this way unless they are clearly doing it in fun.)


> Nathaniel is trying to do the right thing from the start instead, so
> deserves a +1.

I agree.



-- 
Steve


More information about the pypy-dev mailing list