Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r54007:9a9eb5e9b67e
Date: 2012-03-26 14:41 -0400
http://bitbucket.org/pypy/pypy/changeset/9a9eb5e9b67e/
Log: Have bytearray.__getitem__(slice) go through the ll_arraycopy fast
path when possible.
diff --git a/pypy/objspace/std/bytearrayobject.py
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -111,7 +111,10 @@
length = len(data)
start, stop, step, slicelength = w_slice.indices4(space, length)
assert slicelength >= 0
- newdata = [data[start + i*step] for i in range(slicelength)]
+ if step == 1 and 0 <= start <= stop:
+ newdata = data[start:stop]
+ else:
+ newdata = [data[start + i*step] for i in range(slicelength)]
return W_BytearrayObject(newdata)
def contains__Bytearray_Int(space, w_bytearray, w_char):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit