[Python-3000-checkins] r54774 - python/branches/p3yk/Lib/io.py
guido.van.rossum
python-3000-checkins at python.org
Thu Apr 12 07:24:25 CEST 2007
Author: guido.van.rossum
Date: Thu Apr 12 07:24:24 2007
New Revision: 54774
Modified:
python/branches/p3yk/Lib/io.py
Log:
TextIO improvement:
- 25% speed increse in tell();
- f.seek(0, 1) now maps to f.seek(f.tell(), 0) instead of to f.tell().
Modified: python/branches/p3yk/Lib/io.py
==============================================================================
--- python/branches/p3yk/Lib/io.py (original)
+++ python/branches/p3yk/Lib/io.py Thu Apr 12 07:24:24 2007
@@ -992,8 +992,9 @@
return self._encode_decoder_state(decoder_state, position)
decoder = pickle.loads(decoder_state)
n = 0
- for i, b in enumerate(readahead):
- n += len(decoder.decode(bytes([b])))
+ bb = bytes(1)
+ for i, bb[0] in enumerate(readahead):
+ n += len(decoder.decode(bb))
if n >= needed:
decoder_state = pickle.dumps(decoder, 2)
return self._encode_decoder_state(decoder_state, position+i+1)
@@ -1005,7 +1006,8 @@
if whence == 1:
if pos != 0:
raise IOError("Can't do nonzero cur-relative seeks")
- return self.tell()
+ pos = self.tell()
+ whence = 0
if whence == 2:
if pos != 0:
raise IOError("Can't do nonzero end-relative seeks")
More information about the Python-3000-checkins
mailing list