[pypy-commit] pypy missing-ndarray-attributes: pass byteswap tests
mattip
noreply at buildbot.pypy.org
Fri Jan 18 01:16:59 CET 2013
Author: mattip <matti.picus at gmail.com>
Branch: missing-ndarray-attributes
Changeset: r60162:a626fbc58e73
Date: 2013-01-18 01:45 +0200
http://bitbucket.org/pypy/pypy/changeset/a626fbc58e73/
Log: pass byteswap tests
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
@@ -966,6 +966,12 @@
raw_storage_setitem(storage, i + offset,
rffi.cast(self._STORAGE_T, hbits))
+ def byteswap(self, w_v):
+ value = self.unbox(w_v)
+ hbits = float_pack(value,2)
+ swapped = byteswap(rffi.cast(self._STORAGE_T, hbits))
+ return self.box(float_unpack(r_ulonglong(swapped), 2))
+
class NonNativeFloat16(Float16):
_attrs_ = ()
BoxType = interp_boxes.W_Float16Box
@@ -1047,6 +1053,10 @@
def get_element_size(self):
return 2 * rffi.sizeof(self._COMPONENTS_T)
+ def byteswap(self, w_v):
+ real, imag = self.unbox(w_v)
+ return self.box_complex(byteswap(real), byteswap(imag))
+
@specialize.argtype(1)
def box(self, value):
return self.BoxType(
More information about the pypy-commit
mailing list