[Python-Dev] lifting of prohibition against readlines inside a "for line in file" in Py3?

Antoine Pitrou solipsis at pitrou.net
Wed Feb 18 22:25:59 CET 2009


Hello,

Nick Coghlan <ncoghlan <at> gmail.com> writes:
> 
> I *think* the 2.x system had an internal buffer that was used by the
> file iterator, but not by the file methods. With the new IO stack for
> 3.0, there is now a common buffer shared by all the file operations
> (including iteration).
> 
> However, given that the lifting of the restriction is currently
> undocumented, I wouldn't want to see a commitment to keeping it lifted
> until we know that it won't cause any problems for the io-in-c rewrite
> for 3.1 (hopefully someone with more direct involvement with that
> rewrite will chime in, since they'll know a lot more about it than I do).

As you said, there is no special buffering for the file iterator in 3.x, which
means the restriction could be lifted (actually there is nothing relying on this
restriction in the current code, except perhaps the "telling" flag in
TextIOWrapper).

Regards

Antoine.




More information about the Python-Dev mailing list