[pypy-commit] pypy default: Inline W_MemoryView.getslice() and simplify.
Manuel Jacob
noreply at buildbot.pypy.org
Thu May 22 04:18:29 CEST 2014
Author: Manuel Jacob
Branch:
Changeset: r71661:6e9376d22e0e
Date: 2014-05-22 02:37 +0200
http://bitbucket.org/pypy/pypy/changeset/6e9376d22e0e/
Log: Inline W_MemoryView.getslice() and simplify.
diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -61,15 +61,6 @@
def getlength(self):
return self.buf.getlength()
- def getslice(self, start, stop):
- if start < 0:
- start = 0
- size = stop - start
- if size < 0:
- size = 0
- buf = SubBuffer(self.buf, start, size)
- return W_MemoryView(buf)
-
def descr_tobytes(self, space):
return space.wrap(self.as_str())
@@ -81,13 +72,14 @@
return space.newlist(result)
def descr_getitem(self, space, w_index):
- start, stop, step = space.decode_index(w_index, self.getlength())
+ start, stop, step, size = space.decode_index4(w_index, self.getlength())
if step not in (0, 1):
raise oefmt(space.w_NotImplementedError, "")
if step == 0: # index only
return space.wrap(self.buf.getitem(start))
- res = self.getslice(start, stop)
- return space.wrap(res)
+ else:
+ buf = SubBuffer(self.buf, start, size)
+ return W_MemoryView(buf)
def descr_setitem(self, space, w_index, w_obj):
if self.buf.readonly:
More information about the pypy-commit
mailing list