[pypy-commit] pypy default: Have bytearray.__getitem__(slice) go through the ll_arraycopy fast path when possible.
alex_gaynor
noreply at buildbot.pypy.org
Mon Mar 26 20:41:22 CEST 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
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):
More information about the pypy-commit
mailing list