Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r91058:1e60d5cc28f1
Date: 2017-04-15 17:12 +0200
http://bitbucket.org/pypy/pypy/changeset/1e60d5cc28f1/
Log: Temporary performance fix for turning a memoryview to bytes
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
@@ -143,6 +143,14 @@
strides = self.getstrides()
itemsize = self.getitemsize()
bytesize = self.getlength()
+ # optimization only: if the loop below would enumerate all
+ # bytes without any gap, then grab them all at once
+ # XXX review the whole thing (I suspect it's being done in a branch)
+ if itemsize == strides[0]:
+ bytecount = min(bytesize - off, step * itemsize)
+ bytes = self.buf.getslice(off, off+bytecount, 1, bytecount)
+ data.append(bytes)
+ return
copiedbytes = 0
for i in range(step):
bytes = self.buf.getslice(off, off+itemsize, 1, itemsize)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit