[pypy-commit] pypy default: Add a readline() method to speed up reading lines out of a text file on
arigo
noreply at buildbot.pypy.org
Fri Sep 5 17:10:35 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
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)
More information about the pypy-commit
mailing list