[pypy-commit] pypy numpy-record-dtypes: yet another approach

fijal noreply at buildbot.pypy.org
Tue Feb 7 13:13:55 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-record-dtypes
Changeset: r52168:e78857e41456
Date: 2012-02-07 13:28 +0200
http://bitbucket.org/pypy/pypy/changeset/e78857e41456/

Log:	yet another approach

diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -212,7 +212,9 @@
     def min(self, v1, v2):
         return min(v1, v2)
 
-class NonNativePrimitive(object):
+class NonNativePrimitive(Primitive):
+    _mixin_ = True
+    
     def _read(self, storage, width, i, offset):
         return byteswap(Primitive._read(self, storage, width, i, offset))
 
@@ -516,7 +518,6 @@
     def isinf(self, v):
         return rfloat.isinf(v)
 
-
 class Float32(BaseType, Float):
     T = rffi.FLOAT
     BoxType = interp_boxes.W_Float32Box
@@ -538,15 +539,15 @@
 del tp
 
 def _setup():
-    from pypy.tool.sourcetools import func_with_new_name
+    #from pypy.tool.sourcetools import func_with_new_name
     
     for name, tp in globals().items():
-        if isinstance(tp, type):
-            class NonNative(tp):
+        if isinstance(tp, type) and issubclass(tp, BaseType):
+            class NonNative(NonNativePrimitive, tp):
                 pass
-            for item, v in NonNativePrimitive.__dict__.items():
-                if not item.startswith('__'):
-                    setattr(NonNative, item, func_with_new_name(v, item))
+            #for item, v in NonNativePrimitive.__dict__.items():
+            #    if not item.startswith('__'):
+            #        setattr(NonNative, item, func_with_new_name(v, item))
             NonNative.__name__ = 'NonNative' + name
             globals()[NonNative.__name__] = NonNative
 


More information about the pypy-commit mailing list