[pypy-commit] pypy ufuncapi: move implementation-level methods to base file to simplify circular imports

mattip noreply at buildbot.pypy.org
Tue Dec 2 12:52:31 CET 2014


Author: mattip <matti.picus at gmail.com>
Branch: ufuncapi
Changeset: r74780:34c0bc5ac7e8
Date: 2014-12-02 13:50 +0200
http://bitbucket.org/pypy/pypy/changeset/34c0bc5ac7e8/

Log:	move implementation-level methods to base file to simplify circular
	imports

diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py
--- a/pypy/module/micronumpy/base.py
+++ b/pypy/module/micronumpy/base.py
@@ -25,6 +25,7 @@
 
 class W_NDimArray(W_NumpyObject):
     __metaclass__ = extendabletype
+    _immutable_fields_ = ['implementation']
 
     def __init__(self, implementation):
         from pypy.module.micronumpy.concrete import BaseConcreteArray
@@ -98,6 +99,19 @@
         w_arr.set_scalar_value(w_scalar)
         return w_arr
 
+    def get_shape(self):
+        return self.implementation.get_shape()
+
+    def get_dtype(self):
+        return self.implementation.dtype
+
+    def get_order(self):
+        return self.implementation.order
+
+    def ndims(self):
+        return len(self.get_shape())
+    ndims._always_inline_ = True
+
 
 def convert_to_array(space, w_obj):
     from pypy.module.micronumpy.ctors import array
diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -50,9 +50,6 @@
         shape = self.get_shape()
         return space.newtuple([space.wrap(i) for i in shape])
 
-    def get_shape(self):
-        return self.implementation.get_shape()
-
     def descr_set_shape(self, space, w_new_shape):
         shape = get_shape_from_iterable(space, self.get_size(), w_new_shape)
         self.implementation = self.implementation.set_shape(space, self, shape)
@@ -61,12 +58,6 @@
         strides = self.implementation.get_strides()
         return space.newtuple([space.wrap(i) for i in strides])
 
-    def get_dtype(self):
-        return self.implementation.dtype
-
-    def get_order(self):
-        return self.implementation.order
-
     def descr_get_dtype(self, space):
         return self.implementation.dtype
 
@@ -83,10 +74,6 @@
         raise OperationError(space.w_AttributeError, space.wrap(
             "Cannot delete array dtype"))
 
-    def ndims(self):
-        return len(self.get_shape())
-    ndims._always_inline_ = True
-
     def descr_get_ndim(self, space):
         return space.wrap(self.ndims())
 


More information about the pypy-commit mailing list