[pypy-commit] pypy numpy-record-dtypes: update record dtypes until they match

fijal noreply at buildbot.pypy.org
Fri Feb 17 15:17:39 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-record-dtypes
Changeset: r52585:5fa9d10a397d
Date: 2012-02-17 16:08 +0200
http://bitbucket.org/pypy/pypy/changeset/5fa9d10a397d/

Log:	update record dtypes until they match

diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -170,9 +170,9 @@
     pass
 
 class W_VoidBox(W_FlexibleBox):
-    def __init__(self, arr, i):
+    def __init__(self, arr, ofs):
         self.arr = arr # we have to keep array alive
-        self.i = i
+        self.ofs = ofs
 
     def get_dtype(self, space):
         return self.arr.dtype
@@ -184,8 +184,7 @@
         except KeyError:
             raise OperationError(space.w_IndexError,
                                  space.wrap("Field %s does not exist" % item))
-        width = self.arr.dtype.itemtype.get_element_size()
-        return dtype.itemtype.read(self.arr, width, self.i, ofs)
+        return dtype.itemtype.read(self.arr, 1, self.ofs, ofs)
 
     @unwrap_spec(item=str)
     def descr_setitem(self, space, item, w_value):
@@ -194,8 +193,7 @@
         except KeyError:
             raise OperationError(space.w_IndexError,
                                  space.wrap("Field %s does not exist" % item))
-        width = self.arr.dtype.itemtype.get_element_size()
-        dtype.itemtype.store(self.arr, width, self.i, ofs,
+        dtype.itemtype.store(self.arr, 1, self.ofs, ofs,
                              dtype.coerce(space, w_value))
 
 class W_CharacterBox(W_FlexibleBox):
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
@@ -672,14 +672,13 @@
             ofs, itemtype = self.offsets_and_fields[i]
             w_item = items_w[i]
             w_box = itemtype.coerce(space, subdtype, w_item)
-            width = itemtype.get_element_size()
-            itemtype.store(arr, width, 0, ofs, w_box)
+            itemtype.store(arr, 1, 0, ofs, w_box)
         return interp_boxes.W_VoidBox(arr, 0)
 
     @jit.unroll_safe
-    def store(self, arr, width, i, ofs, box):
-        for k in range(width):
-            arr.storage[k + i * width] = box.arr.storage[k + box.i * width]
+    def store(self, arr, _, i, ofs, box):
+        for k in range(self.get_element_size()):
+            arr.storage[k + i] = box.arr.storage[k + box.ofs]
 
 for tp in [Int32, Int64]:
     if tp.T == lltype.Signed:


More information about the pypy-commit mailing list