[pypy-commit] pypy remove-array-smm: start removing SMMs from array module

fijal noreply at buildbot.pypy.org
Sat Mar 23 02:12:27 CET 2013


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: remove-array-smm
Changeset: r62682:3b16f25b9050
Date: 2013-03-22 18:11 -0700
http://bitbucket.org/pypy/pypy/changeset/3b16f25b9050/

Log:	start removing SMMs from array module

diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -814,7 +814,7 @@
     f = d['f']
     f.func_name = func.func_name
     if unwrap_spec is None:
-        unwrap_spec = {}
+        unwrap_spec = getattr(func, 'unwrap_spec', {})
     else:
         assert isinstance(unwrap_spec, dict)
         unwrap_spec = unwrap_spec.copy()
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -2,7 +2,7 @@
 
 from pypy.interpreter.buffer import RWBuffer
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.gateway import interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec, interpindirect2app
 from pypy.interpreter.typedef import GetSetProperty, make_weakref_descr
 from pypy.module._file.interp_file import W_File
 from pypy.objspace.std.model import W_Object
@@ -52,7 +52,6 @@
     return a
 
 
-array_append = SMM('append', 2)
 array_extend = SMM('extend', 2)
 
 array_count = SMM('count', 2)
@@ -86,6 +85,13 @@
 
 
 class W_ArrayBase(W_Object):
+    def descr_append(self, space, w_x):
+        """ append(x)
+
+        Append new value x to the end of the array.
+        """
+        raise NotImplementedError
+
     @staticmethod
     def register(typeorder):
         typeorder[W_ArrayBase] = []
@@ -97,6 +103,7 @@
     itemsize = GetSetProperty(descr_itemsize),
     typecode = GetSetProperty(descr_typecode),
     __weakref__ = make_weakref_descr(W_ArrayBase),
+    append = interpindirect2app(W_ArrayBase.descr_append),
 )
 W_ArrayBase.typedef.registermethods(globals())
 
@@ -343,6 +350,13 @@
                 item = float(item)
             return space.wrap(item)
 
+        # interface
+
+        def descr_append(self, space, w_x):
+            x = self.item_w(w_x)
+            self.setlen(self.len + 1)
+            self.buffer[self.len - 1] = x
+
     # Basic get/set/append/extend methods
 
     def len__Array(space, self):
@@ -394,11 +408,6 @@
     def setslice__Array_ANY_ANY_ANY(space, self, w_i, w_j, w_x):
         space.setitem(self, space.newslice(w_i, w_j, space.w_None), w_x)
 
-    def array_append__Array_ANY(space, self, w_x):
-        x = self.item_w(w_x)
-        self.setlen(self.len + 1)
-        self.buffer[self.len - 1] = x
-
     def array_extend__Array_ANY(space, self, w_iterable):
         self.extend(w_iterable)
 


More information about the pypy-commit mailing list