[pypy-commit] pypy default: have BytesIO.truncate() reset to fast path (AT_END) when possible

bdkearns noreply at buildbot.pypy.org
Fri Apr 12 09:48:10 CEST 2013


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r63268:7722fa2d82da
Date: 2013-04-12 03:44 -0400
http://bitbucket.org/pypy/pypy/changeset/7722fa2d82da/

Log:	have BytesIO.truncate() reset to fast path (AT_END) when possible

diff --git a/pypy/module/_io/interp_bytesio.py b/pypy/module/_io/interp_bytesio.py
--- a/pypy/module/_io/interp_bytesio.py
+++ b/pypy/module/_io/interp_bytesio.py
@@ -73,7 +73,10 @@
                 "negative size value"))
 
         self.truncate(size)
-        self.seek(pos)
+        if size == pos:
+            self.seek(0, 2)
+        else:
+            self.seek(pos)
         return space.wrap(size)
 
     def getvalue_w(self, space):


More information about the pypy-commit mailing list