Author: Carl Friedrich Bolz <[email protected]>
Branch: list-strategies
Changeset: r47680:d1f33b15f068
Date: 2011-09-29 14:35 +0200
http://bitbucket.org/pypy/pypy/changeset/d1f33b15f068/
Log: use the much faster float2longlong instead
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -452,7 +452,7 @@
return self.newbool(self.is_w(w_one, w_two))
def is_w(self, w_one, w_two):
- from pypy.rlib.rstruct import ieee
+ from pypy.rlib.longlong2float import float2longlong
w_typeone = self.type(w_one)
# cannot use self.is_w here to not get infinite recursion
if w_typeone is self.w_int:
@@ -461,8 +461,8 @@
elif w_typeone is self.w_float:
if self.type(w_two) is not self.w_float:
return False
- one = ieee.float_pack(self.float_w(w_one), 8)
- two = ieee.float_pack(self.float_w(w_two), 8)
+ one = float2longlong(self.float_w(w_one))
+ two = float2longlong(self.float_w(w_two))
return one == two
elif w_typeone is self.w_long:
return (self.type(w_two) is self.w_long and
@@ -474,10 +474,10 @@
real2 = self.float_w(self.getattr(w_two, self.wrap("real")))
imag1 = self.float_w(self.getattr(w_one, self.wrap("imag")))
imag2 = self.float_w(self.getattr(w_two, self.wrap("imag")))
- real1 = ieee.float_pack(real1, 8)
- real2 = ieee.float_pack(real2, 8)
- imag1 = ieee.float_pack(imag1, 8)
- imag2 = ieee.float_pack(imag2, 8)
+ real1 = float2longlong(real1)
+ real2 = float2longlong(real2)
+ imag1 = float2longlong(imag1)
+ imag2 = float2longlong(imag2)
return real1 == real2 and imag1 == imag2
elif w_typeone is self.w_str:
return (self.type(w_two) is self.w_str and
@@ -490,7 +490,7 @@
def id(self, w_obj):
from pypy.rlib.rbigint import rbigint
from pypy.rlib import objectmodel
- from pypy.rlib.rstruct import ieee
+ from pypy.rlib.longlong2float import float2longlong
w_type = self.type(w_obj)
if w_type is self.w_int:
tag = 1
@@ -500,15 +500,15 @@
return self.or_(self.lshift(w_obj, self.wrap(3)), self.wrap(tag))
elif w_type is self.w_float:
tag = 5
- val = ieee.float_pack(self.float_w(w_obj), 8)
+ val = float2longlong(self.float_w(w_obj))
w_obj = self.newlong_from_rbigint(rbigint.fromrarith_int(val))
return self.or_(self.lshift(w_obj, self.wrap(3)), self.wrap(tag))
elif w_type is self.w_complex:
real = self.float_w(self.getattr(w_obj, self.wrap("real")))
imag = self.float_w(self.getattr(w_obj, self.wrap("imag")))
tag = 5
- real_b = rbigint.fromrarith_int(ieee.float_pack(real, 8))
- imag_b = rbigint.fromrarith_int(ieee.float_pack(imag, 8))
+ real_b = rbigint.fromrarith_int(float2longlong(real))
+ imag_b = rbigint.fromrarith_int(float2longlong(imag))
val = real_b.lshift(8 *
8).or_(imag_b).lshift(3).or_(rbigint.fromint(3))
return self.newlong_from_rbigint(val)
elif w_type is self.w_str:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit