[pypy-commit] pypy remove-string-smm: Remove bytearray.append SMM.

hodgestar noreply at buildbot.pypy.org
Tue Apr 16 22:18:54 CEST 2013


Author: Simon Cross <hodgestar at gmail.com>
Branch: remove-string-smm
Changeset: r63430:0e6b17820f73
Date: 2013-04-16 22:18 +0200
http://bitbucket.org/pypy/pypy/changeset/0e6b17820f73/

Log:	Remove bytearray.append SMM.

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
@@ -84,6 +84,10 @@
             raise OperationError(space.w_ValueError, space.wrap(
                 "value not found in bytearray"))
 
+    def descr_append(self, space, val):
+        self.data.append(val)
+        return space.w_None
+
     def __repr__(w_self):
         """ representation for debugging purposes """
         return "%s(%s)" % (w_self.__class__.__name__, ''.join(w_self.data))
@@ -572,10 +576,6 @@
 # __________________________________________________________
 # Mutability methods
 
-def bytearray_append__Bytearray_ANY(space, w_bytearray, w_item):
-    from pypy.objspace.std.bytearraytype import getbytevalue
-    w_bytearray.data.append(getbytevalue(space, w_item))
-
 def bytearray_extend__Bytearray_Bytearray(space, w_bytearray, w_other):
     w_bytearray.data += w_other.data
 
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
@@ -61,10 +61,17 @@
         """
         raise NotImplementedError
 
+    @unwrap_spec(val='chr')
+    def descr_append(self, space, val):
+        """B.append(int) -> None
+
+        Append a single item to the end of B.
+        """
+        raise NotImplementedError
+
 
 str_join = SMM('join', 2, defaults=(None,-1))
 
-bytearray_append  = SMM('append', 2)
 bytearray_extend  = SMM('extend', 2)
 
 
@@ -214,5 +221,6 @@
     insert=interpindirect2app(W_AbstractBytearrayObject.descr_insert),
     pop=interpindirect2app(W_AbstractBytearrayObject.descr_pop),
     remove=interpindirect2app(W_AbstractBytearrayObject.descr_remove),
+    append=interpindirect2app(W_AbstractBytearrayObject.descr_append),
     )
 bytearray_typedef.registermethods(globals())


More information about the pypy-commit mailing list