[pypy-commit] pypy default: have ArrayBuffer implement getslice when possible

bdkearns noreply at buildbot.pypy.org
Sun May 4 23:11:45 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r71269:76427f9f6ae4
Date: 2014-05-04 17:11 -0400
http://bitbucket.org/pypy/pypy/changeset/76427f9f6ae4/

Log:	have ArrayBuffer implement getslice when possible

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -612,6 +612,15 @@
         data[index] = char
         array._charbuf_stop()
 
+    def getslice(self, start, stop, step, size):
+        if step == 1:
+            data = self.array._charbuf_start()
+            try:
+                return rffi.charpsize2str(rffi.ptradd(data, start), size)
+            finally:
+                self.array._charbuf_stop()
+        return Buffer.getslice(self, start, stop, step, size)
+
     def get_raw_address(self):
         return self.array._charbuf_start()
 
diff --git a/rpython/rlib/buffer.py b/rpython/rlib/buffer.py
--- a/rpython/rlib/buffer.py
+++ b/rpython/rlib/buffer.py
@@ -21,7 +21,6 @@
         "Returns the index'th character in the buffer."
         raise NotImplementedError   # Must be overriden.  No bounds checks.
 
-    @jit.look_inside_iff(lambda self, start, stop, step, size: jit.isconstant(size))
     def getslice(self, start, stop, step, size):
         # May be overridden.  No bounds checks.
         return ''.join([self.getitem(i) for i in range(start, stop, step)])


More information about the pypy-commit mailing list