[pypy-svn] r72198 - pypy/trunk/pypy/lib

arigo at codespeak.net arigo at codespeak.net
Sat Mar 13 11:56:54 CET 2010


Author: arigo
Date: Sat Mar 13 11:56:52 2010
New Revision: 72198

Modified:
   pypy/trunk/pypy/lib/cmath.py
Log:
Precompute sqrt(_half).  Delicate tweaking: are there any test at all??


Modified: pypy/trunk/pypy/lib/cmath.py
==============================================================================
--- pypy/trunk/pypy/lib/cmath.py	(original)
+++ pypy/trunk/pypy/lib/cmath.py	Sat Mar 13 11:56:52 2010
@@ -37,8 +37,7 @@
 
     Return the hyperbolic arccosine of x."""
 
-    z = sqrt(_half)
-    z = log(z*(sqrt(x+_one)+sqrt(x-_one)))
+    z = log(_sqrt_half*(sqrt(x+_one)+sqrt(x-_one)))
     return z+z
 
 
@@ -58,8 +57,7 @@
 
     Return the hyperbolic arc sine of x."""
     
-    z = sqrt(_half)
-    z = log((z * (sqrt(x+_i)+sqrt((x-_i))) ))
+    z = log((_sqrt_half * (sqrt(x+_i)+sqrt((x-_i))) ))
     return z+z
 
 
@@ -183,6 +181,8 @@
             imag = -s
     return complex(real, imag)
 
+_sqrt_half = sqrt(_half)
+
 
 def tan(x):
     """tan(x)



More information about the Pypy-commit mailing list