Matti Picus avatar Matti Picus committed 8045286 Merge

merge heads

Comments (0)

Files changed (2)

pypy/module/micronumpy/types.py

 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib.rstruct.runpack import runpack
 from rpython.rlib.rstruct.nativefmttable import native_is_bigendian
-from rpython.rlib.rstruct.ieee import (float_pack, float_unpack, pack_float,
+from rpython.rlib.rstruct.ieee import (float_pack, float_unpack, pack_float80,
                                     unpack_float, unpack_float128)
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rlib import jit
         def byteswap(self, w_v):
             value = self.unbox(w_v)
             result = StringBuilder(12)
-            pack_float(result, value, 12, not native_is_bigendian)
+            pack_float80(result, value, 12, not native_is_bigendian)
             return self.box(unpack_float128(result.build(), native_is_bigendian))
 
     class NonNativeFloat96(Float96):
         def byteswap(self, w_v):
             value = self.unbox(w_v)
             result = StringBuilder(16)
-            pack_float(result, value, 16, not native_is_bigendian)
+            pack_float80(result, value, 16, not native_is_bigendian)
             return self.box(unpack_float128(result.build(), native_is_bigendian))
 
     class NonNativeFloat128(Float128):

rpython/rlib/rstruct/ieee.py

 
 
 @jit.unroll_safe
+def pack_float80(result, x, size, be):
+    l = []
+    unsigned = float_pack80(x)
+    for i in range(8):
+        l.append(chr((unsigned[0] >> (i * 8)) & 0xFF))
+    for i in range(size - 8):
+        l.append(chr((unsigned[1] >> (i * 8)) & 0xFF))
+    if be:
+        l.reverse()
+    result.append("".join(l))
+
+@jit.unroll_safe
 def pack_float(result, x, size, be):
     l = []
-    if size == 12 or size == 16:
-        unsigned = float_pack80(x)
-        for i in range(8):
-            l.append(chr((unsigned[0] >> (i * 8)) & 0xFF))
-        for i in range(size - 8):
-            l.append(chr((unsigned[1] >> (i * 8)) & 0xFF))
-    else:
-        unsigned = float_pack(x, size)
-        for i in range(size):
-            l.append(chr((unsigned >> (i * 8)) & 0xFF))
+    unsigned = float_pack(x, size)
+    for i in range(size):
+        l.append(chr((unsigned >> (i * 8)) & 0xFF))
     if be:
         l.reverse()
     result.append("".join(l))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.