[pypy-commit] pypy PyBuffer: optimisation: do not nest BufferSlice objects

rlamy pypy.commits at gmail.com
Tue Apr 25 10:46:56 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: PyBuffer
Changeset: r91124:b669ec17dc42
Date: 2017-04-25 15:46 +0100
http://bitbucket.org/pypy/pypy/changeset/b669ec17dc42/

Log:	optimisation: do not nest BufferSlice objects

diff --git a/pypy/interpreter/buffer.py b/pypy/interpreter/buffer.py
--- a/pypy/interpreter/buffer.py
+++ b/pypy/interpreter/buffer.py
@@ -313,6 +313,11 @@
     def w_getitem(self, space, idx):
         return self.buf.w_getitem(space, self.parent_index(idx))
 
+    def new_slice(self, start, step, slicelength):
+        real_start = start + self.start
+        real_step = self.step * step
+        return BufferSlice(self.buf, real_start, real_step, slicelength)
+
     def setitem_w(self, space, idx, w_obj):
         return self.buf.setitem_w(space, self.parent_index(idx), w_obj)
 


More information about the pypy-commit mailing list