[pypy-commit] pypy remove-remaining-smm: Move floatobject's float2string to module level again (for numpy).
Manuel Jacob
noreply at buildbot.pypy.org
Tue Feb 25 04:45:58 CET 2014
Author: Manuel Jacob
Branch: remove-remaining-smm
Changeset: r69387:499401528ec4
Date: 2014-02-25 04:33 +0100
http://bitbucket.org/pypy/pypy/changeset/499401528ec4/
Log: Move floatobject's float2string to module level again (for numpy).
diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py
--- a/pypy/objspace/std/floatobject.py
+++ b/pypy/objspace/std/floatobject.py
@@ -21,6 +21,20 @@
from rpython.rlib.unroll import unrolling_iterable
+def float2string(x, code, precision):
+ # we special-case explicitly inf and nan here
+ if isfinite(x):
+ s = formatd(x, code, precision, DTSF_ADD_DOT_0)
+ elif isinf(x):
+ if x > 0.0:
+ s = "inf"
+ else:
+ s = "-inf"
+ else: # isnan(x):
+ s = "nan"
+ return s
+
+
def detect_floatformat():
from rpython.rtyper.lltypesystem import rffi, lltype
buf = lltype.malloc(rffi.CCHARP.TO, 8, flavor='raw')
@@ -356,25 +370,11 @@
if space.isinstance_w(w_obj, space.w_long):
return W_FloatObject(space.float_w(w_obj))
- def _float2string(self, x, code, precision):
- # we special-case explicitly inf and nan here
- if isfinite(x):
- s = formatd(x, code, precision, DTSF_ADD_DOT_0)
- elif isinf(x):
- if x > 0.0:
- s = "inf"
- else:
- s = "-inf"
- else: # isnan(x):
- s = "nan"
- return s
-
def descr_repr(self, space):
- return space.wrap(self._float2string(self.floatval, 'r', 0))
+ return space.wrap(float2string(self.floatval, 'r', 0))
def descr_str(self, space):
- return space.wrap(self._float2string(self.floatval, 'g',
- DTSF_STR_PRECISION))
+ return space.wrap(float2string(self.floatval, 'g', DTSF_STR_PRECISION))
def descr_hash(self, space):
return space.wrap(_hash_float(space, self.floatval))
More information about the pypy-commit
mailing list