Author: Armin Rigo <[email protected]>
Branch:
Changeset: r73319:316def1241d1
Date: 2014-09-05 17:09 +0200
http://bitbucket.org/pypy/pypy/changeset/316def1241d1/
Log: Add a readline() method to speed up reading lines out of a text file
on Windows
diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py
--- a/rpython/rlib/streamio.py
+++ b/rpython/rlib/streamio.py
@@ -900,6 +900,13 @@
return '\n'.join(result)
+ def readline(self):
+ line = self.base.readline()
+ limit = len(line) - 2
+ if limit >= 0 and line[limit] == '\r' and line[limit + 1] == '\n':
+ line = line[:limit] + '\n'
+ return line
+
def tell(self):
pos = self.base.tell()
return pos - len(self.lfbuffer)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit