[pypy-commit] pypy default: Create W_Dtype.read()
rlamy
noreply at buildbot.pypy.org
Sun Jun 7 06:08:08 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r77934:397c54d1f22a
Date: 2015-06-07 04:19 +0100
http://bitbucket.org/pypy/pypy/changeset/397c54d1f22a/
Log: Create W_Dtype.read()
diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py
--- a/pypy/module/micronumpy/boxes.py
+++ b/pypy/module/micronumpy/boxes.py
@@ -573,7 +573,7 @@
if isinstance(dtype.itemtype, VoidType):
read_val = dtype.itemtype.readarray(self.arr, self.ofs, ofs, dtype)
else:
- read_val = dtype.itemtype.read(self.arr, self.ofs, ofs, dtype)
+ read_val = dtype.read(self.arr, self.ofs, ofs)
if isinstance (read_val, W_StringBox):
# StringType returns a str
return space.wrap(dtype.itemtype.to_str(read_val))
diff --git a/pypy/module/micronumpy/concrete.py b/pypy/module/micronumpy/concrete.py
--- a/pypy/module/micronumpy/concrete.py
+++ b/pypy/module/micronumpy/concrete.py
@@ -43,7 +43,7 @@
return backstrides
def getitem(self, index):
- return self.dtype.itemtype.read(self, index, 0)
+ return self.dtype.read(self, index, 0)
def getitem_bool(self, index):
return self.dtype.itemtype.read_bool(self, index, 0)
diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py
--- a/pypy/module/micronumpy/descriptor.py
+++ b/pypy/module/micronumpy/descriptor.py
@@ -405,6 +405,9 @@
def store(self, arr, i, offset, value):
return self.itemtype.store(arr, i, offset, value)
+ def read(self, arr, i, offset):
+ return self.itemtype.read(arr, i, offset, self)
+
def descr_reduce(self, space):
w_class = space.type(self)
builder_args = space.newtuple([
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
@@ -2322,10 +2322,11 @@
ret_unwrapped = []
for name in dt.names:
ofs, dtype = dt.fields[name]
+ # XXX: code duplication with W_VoidBox.descr_getitem()
if isinstance(dtype.itemtype, VoidType):
read_val = dtype.itemtype.readarray(item.arr, ofs, 0, dtype)
else:
- read_val = dtype.itemtype.read(item.arr, ofs, 0, dtype)
+ read_val = dtype.read(item.arr, ofs, 0)
if isinstance (read_val, boxes.W_StringBox):
# StringType returns a str
read_val = space.wrap(dtype.itemtype.to_str(read_val))
@@ -2419,9 +2420,8 @@
dtype = box.dtype
for name in dtype.names:
ofs, subdtype = dtype.fields[name]
- itemtype = subdtype.itemtype
- subbox = itemtype.read(box.arr, box.ofs, ofs, subdtype)
- items.append(itemtype.to_builtin_type(space, subbox))
+ subbox = subdtype.read(box.arr, box.ofs, ofs)
+ items.append(subdtype.itemtype.to_builtin_type(space, subbox))
return space.newtuple(items)
@jit.unroll_safe
@@ -2431,12 +2431,12 @@
first = True
for name in box.dtype.names:
ofs, subdtype = box.dtype.fields[name]
- tp = subdtype.itemtype
if first:
first = False
else:
pieces.append(", ")
- val = tp.read(box.arr, box.ofs, ofs, subdtype)
+ val = subdtype.read(box.arr, box.ofs, ofs)
+ tp = subdtype.itemtype
pieces.append(tp.str_format(val, add_quotes=add_quotes))
pieces.append(")")
return "".join(pieces)
More information about the pypy-commit
mailing list