Author: Simon Cross <[email protected]>
Branch: remove-string-smm
Changeset: r63431:58d8ca4f8154
Date: 2013-04-16 22:26 +0200
http://bitbucket.org/pypy/pypy/changeset/58d8ca4f8154/
Log: Remove bytearray.extend multi-method and some unneeded return
space.w_Nones (fijal, hodgestar).
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
@@ -64,7 +64,6 @@
def descr_insert(self, space, index, val):
self.data.insert(index, val)
- return space.w_None
def descr_pop(self, space, index=-1):
try:
@@ -86,7 +85,14 @@
def descr_append(self, space, val):
self.data.append(val)
- return space.w_None
+
+ def descr_extend(self, space, w_iterable):
+ if isinstance(w_iterable, W_BytearrayObject):
+ self.data.extend(w_iterable.data)
+ return
+ for w_item in space.listview(w_iterable):
+ c = space.gateway_chr_w(w_item)
+ self.data.append(c)
def __repr__(w_self):
""" representation for debugging purposes """
@@ -576,12 +582,6 @@
# __________________________________________________________
# Mutability methods
-def bytearray_extend__Bytearray_Bytearray(space, w_bytearray, w_other):
- w_bytearray.data += w_other.data
-
-def bytearray_extend__Bytearray_ANY(space, w_bytearray, w_other):
- w_bytearray.data += makebytearraydata_w(space, w_other)
-
def inplace_add__Bytearray_Bytearray(space, w_bytearray1, w_bytearray2):
bytearray_extend__Bytearray_Bytearray(space, w_bytearray1, w_bytearray2)
return w_bytearray1
diff --git a/pypy/objspace/std/bytearraytype.py
b/pypy/objspace/std/bytearraytype.py
--- a/pypy/objspace/std/bytearraytype.py
+++ b/pypy/objspace/std/bytearraytype.py
@@ -69,12 +69,16 @@
"""
raise NotImplementedError
+ def descr_extend(self, space, w_iterable):
+ """B.extend(iterable int) -> None
+
+ Append all the elements from the iterator or sequence to the
+ end of B.
+ """
+ raise NotImplementedError
str_join = SMM('join', 2, defaults=(None,-1))
-bytearray_extend = SMM('extend', 2)
-
-
bytearray_reverse = SMM('reverse', 1,
doc="B.reverse() -> None\n\n"
@@ -222,5 +226,6 @@
pop=interpindirect2app(W_AbstractBytearrayObject.descr_pop),
remove=interpindirect2app(W_AbstractBytearrayObject.descr_remove),
append=interpindirect2app(W_AbstractBytearrayObject.descr_append),
+ extend=interpindirect2app(W_AbstractBytearrayObject.descr_extend),
)
bytearray_typedef.registermethods(globals())
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit