[pypy-svn] r75747 - pypy/branch/fast-forward/pypy/module/math
benjamin at codespeak.net
benjamin at codespeak.net
Fri Jul 2 00:08:49 CEST 2010
Author: benjamin
Date: Fri Jul 2 00:08:48 2010
New Revision: 75747
Modified:
pypy/branch/fast-forward/pypy/module/math/__init__.py
pypy/branch/fast-forward/pypy/module/math/interp_math.py
Log:
add copysign, isinf, and isnan
Modified: pypy/branch/fast-forward/pypy/module/math/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/math/__init__.py (original)
+++ pypy/branch/fast-forward/pypy/module/math/__init__.py Fri Jul 2 00:08:48 2010
@@ -11,6 +11,7 @@
'pi' : 'interp_math.get(space).w_pi',
'pow' : 'interp_math.pow',
'cosh' : 'interp_math.cosh',
+ 'copysign' : 'interp_math.copysign',
'ldexp' : 'interp_math.ldexp',
'hypot' : 'interp_math.hypot',
'tan' : 'interp_math.tan',
@@ -34,5 +35,7 @@
'modf' : 'interp_math.modf',
'exp' : 'interp_math.exp',
'acos' : 'interp_math.acos',
+ 'isinf' : 'interp_math.isinf',
+ 'isnan' : 'interp_math.isnan',
}
Modified: pypy/branch/fast-forward/pypy/module/math/interp_math.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/math/interp_math.py (original)
+++ pypy/branch/fast-forward/pypy/module/math/interp_math.py Fri Jul 2 00:08:48 2010
@@ -1,5 +1,6 @@
-
import math
+
+from pypy.rlib import rarithmetic
from pypy.interpreter.error import OperationError
from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped
@@ -46,6 +47,22 @@
return space.wrap(r)
math2._annspecialcase_ = 'specialize:arg(1)'
+def copysign(space, x, y):
+ """Return x with the sign of y."""
+ # No exceptions possible.
+ return space.wrap(rarithmetic.copysign(x, y))
+copysign.unwrap_spec = [ObjSpace, float, float]
+
+def isinf(space, x):
+ """Return True if x is infinity."""
+ return space.wrap(rarithmetic.isinf(x))
+isinf.unwrap_spec = [ObjSpace, float, float]
+
+def isnan(space, x):
+ """Return True if x is not a number."""
+ return space.wrap(rarithmetic.isnan(x))
+isnan.unwrap_spec = [ObjSpace, float, float]
+
def pow(space, x, y):
"""pow(x,y)
More information about the Pypy-commit
mailing list