[pypy-svn] pypy arm-backend-2: merge default

bivab commits-noreply at bitbucket.org
Wed Feb 2 13:49:56 CET 2011


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r41546:1e9a43942d1d
Date: 2011-01-20 17:05 +0100
http://bitbucket.org/pypy/pypy/changeset/1e9a43942d1d/

Log:	merge default

diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -388,8 +388,9 @@
         else:
             raise ValueError(word)
 
-    hasbackendopts = 'nobackendopt' not in words
-    config.translation.suggest(list_comprehension_operations=hasbackendopts)
+    # list_comprehension_operations is needed for translation, because
+    # make_sure_not_resized often relies on it, so we always enable them
+    config.translation.suggest(list_comprehension_operations=True)
 
 # ----------------------------------------------------------------
 

diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -667,13 +667,10 @@
 class AppTestModuleDict(object):
     def setup_class(cls):
         cls.space = gettestobjspace(**{"objspace.std.withcelldict": True})
-        cls.w_impl_used = cls.space.appexec([], """():
-            import __pypy__
-            def impl_used(obj):
-                assert "ModuleDictImplementation" in __pypy__.internal_repr(obj)
-            return impl_used
-        """)
 
+    def w_impl_used(self, obj):
+        import __pypy__
+        assert "ModuleDictImplementation" in __pypy__.internal_repr(obj)
 
     def test_check_module_uses_module_dict(self):
         m = type(__builtins__)("abc")

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -128,7 +128,7 @@
 
         for name in ('int', 'long', 'str', 'unicode'):
             setattr(self, 'w_' + name, eval(name))
-        
+
 
     def appexec(self, args, body):
         body = body.lstrip()
@@ -294,16 +294,6 @@
     py.test.skip("need translated pypy with: %s, got %s"
                  %(ropts,options))
 
-def getwithoutbinding(x, name):
-    try:
-        return x.__dict__[name]
-    except (AttributeError, KeyError):
-        for cls in getmro(x.__class__):
-            if name in cls.__dict__:
-                return cls.__dict__[name]
-        # uh? not found anywhere, fall back (which might raise AttributeError)
-        return getattr(x, name)
-
 class LazyObjSpaceGetter(object):
     def __get__(self, obj, cls=None):
         space = gettestobjspace()
@@ -429,10 +419,7 @@
         for name in dir(instance):
             if name.startswith('w_'):
                 if option.runappdirect:
-                    # if the value is a function living on the class,
-                    # don't turn it into a bound method here
-                    obj = getwithoutbinding(instance, name)
-                    setattr(instance, name[2:], obj)
+                    setattr(instance, name[2:], getattr(instance, name))
                 else:
                     obj = getattr(instance, name)
                     if isinstance(obj, types.MethodType):

diff --git a/pypy/translator/platform/__init__.py b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -176,8 +176,11 @@
     def _finish_linking(self, ofiles, eci, outputfilename, standalone):
         if outputfilename is None:
             outputfilename = ofiles[0].purebasename
-        exe_name = py.path.local(os.path.join(str(ofiles[0].dirpath()),
-                                              outputfilename))
+        if ofiles:
+            dirname = ofiles[0].dirpath()
+        else:
+            dirname = udir.join('module_cache')
+        exe_name = dirname.join(outputfilename, abs=True)
         if standalone:
             if self.exe_ext:
                 exe_name += '.' + self.exe_ext

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -362,10 +362,19 @@
             self.setlen(0)
             self.fromsequence(w_lst)
         else:
-            j = 0
-            for i in range(start, stop, step):
-                self.buffer[i] = w_item.buffer[j]
-                j += 1
+            if self is w_item:
+                with lltype.scoped_alloc(mytype.arraytype, self.allocated) as new_buffer:
+                    for i in range(self.len):
+                        new_buffer[i] = w_item.buffer[i]
+                    j = 0
+                    for i in range(start, stop, step):
+                        self.buffer[i] = new_buffer[j]
+                        j += 1
+            else:
+                j = 0
+                for i in range(start, stop, step):
+                    self.buffer[i] = w_item.buffer[j]
+                    j += 1
 
     def setslice__Array_ANY_ANY_ANY(space, self, w_i, w_j, w_x):
         space.setitem(self, space.newslice(w_i, w_j, space.w_None), w_x)

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1156,38 +1156,66 @@
         # This is here mostly just for gateway.int_unwrapping_space_method().
         return bool(self.int_w(w_obj))
 
-    def nonnegint_w(self, w_obj):
-        # Like space.int_w(), but raises an app-level ValueError if
-        # the integer is negative.  Mostly here for gateway.py.
-        value = self.int_w(w_obj)
+    # This is all interface for gateway.py.
+    def gateway_int_w(self, w_obj):
+        if self.is_true(self.isinstance(w_obj, self.w_float)):
+            raise OperationError(self.w_TypeError,
+                            self.wrap("integer argument expected, got float"))
+        return self.int_w(self.int(w_obj))
+
+    def gateway_float_w(self, w_obj):
+        return self.float_w(self.float(w_obj))
+
+    def gateway_r_longlong_w(self, w_obj):
+        if self.is_true(self.isinstance(w_obj, self.w_float)):
+            raise OperationError(self.w_TypeError,
+                            self.wrap("integer argument expected, got float"))
+        return self.r_longlong_w(self.int(w_obj))
+
+    def gateway_r_uint_w(self, w_obj):
+        if self.is_true(self.isinstance(w_obj, self.w_float)):
+            raise OperationError(self.w_TypeError,
+                            self.wrap("integer argument expected, got float"))
+        return self.uint_w(self.int(w_obj))
+
+    def gateway_r_ulonglong_w(self, w_obj):
+        if self.is_true(self.isinstance(w_obj, self.w_float)):
+            raise OperationError(self.w_TypeError,
+                            self.wrap("integer argument expected, got float"))
+        return self.r_ulonglong_w(self.int(w_obj))
+
+    def gateway_nonnegint_w(self, w_obj):
+        # Like space.gateway_int_w(), but raises an app-level ValueError if
+        # the integer is negative.  Here for gateway.py.
+        value = self.gateway_int_w(w_obj)
         if value < 0:
             raise OperationError(self.w_ValueError,
                                  self.wrap("expected a non-negative integer"))
         return value
 
     def c_int_w(self, w_obj):
-        # Like space.int_w(), but raises an app-level OverflowError if
-        # the integer does not fit in 32 bits.  Mostly here for gateway.py.
-        value = self.int_w(w_obj)
+        # Like space.gateway_int_w(), but raises an app-level OverflowError if
+        # the integer does not fit in 32 bits.  Here for gateway.py.
+        value = self.gateway_int_w(w_obj)
         if value < -2147483647-1 or value > 2147483647:
             raise OperationError(self.w_OverflowError,
                                  self.wrap("expected a 32-bit integer"))
         return value
 
     def c_uint_w(self, w_obj):
-        # Like space.uint_w(), but raises an app-level OverflowError if
-        # the integer does not fit in 32 bits.  Mostly here for gateway.py.
-        value = self.uint_w(w_obj)
+        # Like space.gateway_uint_w(), but raises an app-level OverflowError if
+        # the integer does not fit in 32 bits.  Here for gateway.py.
+        value = self.gateway_r_uint_w(w_obj)
         if value > UINT_MAX_32_BITS:
             raise OperationError(self.w_OverflowError,
                               self.wrap("expected an unsigned 32-bit integer"))
         return value
 
     def c_nonnegint_w(self, w_obj):
-        # Like space.int_w(), but raises an app-level ValueError if
-        # the integer is negative or does not fit in 32 bits.  Mostly here
+        # Like space.gateway_int_w(), but raises an app-level ValueError if
+        # the integer is negative or does not fit in 32 bits.  Here
         # for gateway.py.
-        value = self.int_w(w_obj)
+        value = self.gateway_int_w(w_obj)
         if value < 0:
             raise OperationError(self.w_ValueError,
                                  self.wrap("expected a non-negative integer"))
@@ -1197,6 +1225,10 @@
         return value
 
     def c_filedescriptor_w(self, w_fd):
+        # This is only used sometimes in CPython, e.g. for os.fsync() but
+        # not os.close().  It's likely designed for 'select'.  It's irregular
+        # in the sense that it expects either a real int/long or an object
+        # with a fileno(), but not an object with an __int__().
         if (not self.isinstance_w(w_fd, self.w_int) and
             not self.isinstance_w(w_fd, self.w_long)):
             try:

diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -36,7 +36,9 @@
     group.addoption('--pypy', action="store", type="string",
        dest="pypy",  help="use given pypy executable to run lib-python tests. "
                           "This will run the tests directly (i.e. not through py.py)")
-   
+    group.addoption('--filter', action="store", type="string", default=None,
+                    dest="unittest_filter",  help="Similar to -k, XXX")
+
 option = py.test.config.option 
 
 def gettimeout(): 
@@ -688,7 +690,14 @@
             else:
                 status = 'abnormal termination 0x%x' % status
         else:
-            status = os.system("%s >>%s 2>>%s" %(cmd, stdout, stderr))
+            if self.config.option.unittest_filter is not None:
+                cmd += ' --filter %s' % self.config.option.unittest_filter
+            if self.config.option.usepdb:
+                cmd += ' --pdb'
+            if self.config.option.capture == 'no':
+                status = os.system(cmd)
+            else:
+                status = os.system("%s >>%s 2>>%s" %(cmd, stdout, stderr))
             if os.WIFEXITED(status):
                 status = os.WEXITSTATUS(status)
             else:

diff --git a/pypy/module/signal/interp_signal.py b/pypy/module/signal/interp_signal.py
--- a/pypy/module/signal/interp_signal.py
+++ b/pypy/module/signal/interp_signal.py
@@ -1,11 +1,15 @@
+from __future__ import with_statement
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import W_Root, ObjSpace
 from pypy.interpreter.executioncontext import AsyncAction, AbstractActionFlag
 from pypy.interpreter.executioncontext import PeriodicAsyncAction
+from pypy.interpreter.gateway import unwrap_spec
 import signal as cpy_signal
 from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.tool import rffi_platform
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 import py
+import sys
 from pypy.tool import autopath
 from pypy.rlib import jit, rposix
 from pypy.rlib.rarithmetic import intmask
@@ -21,8 +25,12 @@
 SIG_IGN = cpy_signal.SIG_IGN
 signal_names = list(setup())
 
+includes = ['stdlib.h', 'src/signals.h']
+if sys.platform != 'win32':
+    includes.append('sys/time.h')
+
 eci = ExternalCompilationInfo(
-    includes = ['stdlib.h', 'src/signals.h'],
+    includes = includes,
     separate_module_sources = ['#include <src/signals.h>'],
     include_dirs = [str(py.path.local(autopath.pypydir).join('translator', 'c'))],
     export_symbols = ['pypysig_poll', 'pypysig_default',
@@ -31,6 +39,26 @@
                       'pypysig_getaddr_occurred'],
 )
 
+class CConfig:
+    _compilation_info_ = eci
+
+if sys.platform != 'win32':
+    for name in """ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF""".split():
+        setattr(CConfig, name, rffi_platform.DefinedConstantInteger(name))
+
+    CConfig.timeval = rffi_platform.Struct(
+        'struct timeval',
+        [('tv_sec', rffi.LONG),
+         ('tv_usec', rffi.LONG)])
+
+    CConfig.itimerval = rffi_platform.Struct(
+        'struct itimerval',
+        [('it_value', CConfig.timeval),
+         ('it_interval', CConfig.timeval)])
+
+for k, v in rffi_platform.configure(CConfig).items():
+    globals()[k] = v
+
 def external(name, args, result, **kwds):
     return rffi.llexternal(name, args, result, compilation_info=eci, **kwds)
 
@@ -55,6 +83,12 @@
 c_pause = external('pause', [], rffi.INT)
 c_siginterrupt = external('siginterrupt', [rffi.INT, rffi.INT], rffi.INT)
 
+if sys.platform != 'win32':
+    itimervalP = rffi.CArrayPtr(itimerval)
+    c_setitimer = external('setitimer',
+                           [rffi.INT, itimervalP, itimervalP], rffi.INT)
+    c_getitimer = external('getitimer', [rffi.INT, itimervalP], rffi.INT)
+
 
 class SignalActionFlag(AbstractActionFlag):
     # This class uses the C-level pypysig_counter variable as the tick
@@ -252,3 +286,41 @@
         errno = rposix.get_errno()
         raise OperationError(space.w_RuntimeError, space.wrap(errno))
 siginterrupt.unwrap_spec = [ObjSpace, int, int]
+
+
+#__________________________________________________________
+
+def timeval_from_double(d, timeval):
+    timeval.c_tv_sec = int(d)
+    timeval.c_tv_usec = int((d - int(d)) * 1000000)
+
+def double_from_timeval(tv):
+    return tv.c_tv_sec + (tv.c_tv_usec / 1000000.0)
+
+def itimer_retval(space, val):
+    w_value = space.wrap(double_from_timeval(val.c_it_value))
+    w_interval = space.wrap(double_from_timeval(val.c_it_interval))
+    return space.newtuple([w_value, w_interval])
+
+ at jit.dont_look_inside
+ at unwrap_spec(ObjSpace, int, float, float)
+def setitimer(space, which, first, interval=0):
+    with lltype.scoped_alloc(itimervalP.TO, 1) as new:
+
+        timeval_from_double(first, new[0].c_it_value)
+        timeval_from_double(interval, new[0].c_it_interval)
+
+        with lltype.scoped_alloc(itimervalP.TO, 1) as old:
+
+            c_setitimer(which, new, old)
+
+            return itimer_retval(space, old[0])
+
+ at jit.dont_look_inside
+ at unwrap_spec(ObjSpace, int)
+def getitimer(space, which):
+    with lltype.scoped_alloc(itimervalP.TO, 1) as old:
+
+        c_getitimer(which, old)
+
+        return itimer_retval(space, old[0])

diff --git a/pypy/jit/metainterp/test/test_optimizeopt.py b/pypy/jit/metainterp/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/test/test_optimizeopt.py
@@ -552,21 +552,47 @@
         """
         self.optimize_loop(ops, expected, preamble)
 
+    def test_bound_int_is_true(self):
+        ops = """
+        [i0]
+        i1 = int_add(i0, 1)
+        i2 = int_gt(i1, 0)
+        guard_true(i2) []
+        i3 = int_is_true(i1)
+        guard_true(i3) []
+        jump(i1)
+        """
+        expected = """
+        [i0]
+        i1 = int_add(i0, 1)
+        jump(i1)
+        """
+        preamble = """
+        [i0]
+        i1 = int_add(i0, 1)
+        i2 = int_gt(i1, 0)
+        guard_true(i2) []
+        jump(i1)
+        """
+        self.optimize_loop(ops, expected, preamble)
+
     def test_int_is_true_is_zero(self):
-        py.test.skip("XXX implement me")
+        py.test.skip("in-progress")
         ops = """
         [i0]
-        i1 = int_is_true(i0)
-        guard_true(i1) []
-        i2 = int_is_zero(i0)
-        guard_false(i2) []
-        jump(i0)
+        i1 = int_add(i0, 1)
+        i2 = int_is_true(i1)
+        guard_true(i2) []
+        i3 = int_is_zero(i1)
+        guard_false(i3) []
+        jump(i1)
         """
         expected = """
         [i0]
-        i1 = int_is_true(i0)
-        guard_true(i1) []
-        jump(i0)
+        i1 = int_add(i0, 1)
+        i2 = int_is_true(i1)
+        guard_true(i2) []
+        jump(i1)
         """
         self.optimize_loop(ops, expected)
 

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
@@ -12,6 +12,7 @@
 from pypy.rlib.rarithmetic import base_int, widen
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.jit import hint
+from pypy.rlib.rbigint import rbigint
 from pypy.tool.sourcetools import func_with_new_name
 
 # Object imports
@@ -181,8 +182,12 @@
                 return self.newint(x)
             else:
                 return W_LongObject.fromrarith_int(x)
+        return self._wrap_not_rpython(x)
+    wrap._annspecialcase_ = "specialize:wrap"
 
-        # _____ below here is where the annotator should not get _____
+    def _wrap_not_rpython(self, x):
+        "NOT_RPYTHON"
+        # _____ this code is here to support testing only _____
 
         # wrap() of a container works on CPython, but the code is
         # not RPython.  Don't use -- it is kept around mostly for tests.
@@ -226,9 +231,6 @@
             return self.w_Ellipsis
 
         if self.config.objspace.nofaking:
-            # annotation should actually not get here.  If it does, you get
-            # an error during rtyping because '%r' is not supported.  It tells
-            # you that there was a space.wrap() on a strange object.
             raise OperationError(self.w_RuntimeError,
                                  self.wrap("nofaking enabled: refusing "
                                            "to wrap cpython value %r" %(x,)))
@@ -239,8 +241,6 @@
         from fake import fake_object
         return fake_object(self, x)
 
-    wrap._annspecialcase_ = "specialize:wrap"
-
     def wrap_exception_cls(self, x):
         """NOT_RPYTHON"""
         if hasattr(self, 'w_' + x.__name__):
@@ -264,9 +264,16 @@
     def newcomplex(self, realval, imagval):
         return W_ComplexObject(realval, imagval)
 
+    def unpackcomplex(self, w_complex):
+        from pypy.objspace.std.complextype import unpackcomplex
+        return unpackcomplex(self, w_complex)
+
     def newlong(self, val): # val is an int
         return W_LongObject.fromint(self, val)
 
+    def newlong_from_rbigint(self, val):
+        return W_LongObject(val)
+
     def newtuple(self, list_w):
         assert isinstance(list_w, list)
         make_sure_not_resized(list_w)

diff --git a/pypy/translator/tool/cbuild.py b/pypy/translator/tool/cbuild.py
--- a/pypy/translator/tool/cbuild.py
+++ b/pypy/translator/tool/cbuild.py
@@ -1,4 +1,5 @@
 import py
+import sys
 
 from pypy.tool.autopath import pypydir
 from pypy.translator.platform import host
@@ -274,10 +275,15 @@
     def compile_shared_lib(self, outputfilename=None):
         self = self.convert_sources_to_files()
         if not self.separate_module_files:
-            return self
+            if sys.platform != 'win32':
+                return self
+            if not self.export_symbols:
+                return self
+            basepath = udir.join('module_cache')
+        else:
+            basepath = py.path.local(self.separate_module_files[0]).dirpath()
         if outputfilename is None:
             # find more or less unique name there
-            basepath = py.path.local(self.separate_module_files[0]).dirpath()
             pth = basepath.join('externmod').new(ext=host.so_ext)
             num = 0
             while pth.check():

diff --git a/lib_pypy/cmath.py b/lib_pypy/cmath.py
deleted file mode 100644
--- a/lib_pypy/cmath.py
+++ /dev/null
@@ -1,288 +0,0 @@
-"""This module is always available. It provides access to mathematical
-functions for complex numbers."""
-
-# Complex math module
-
-# much code borrowed from mathmodule.c
-
-import math
-from math import e, pi
-
-try: from __pypy__ import builtinify
-except ImportError: builtinify = lambda f: f
-
-
-# constants
-_one = complex(1., 0.)
-_half = complex(0.5, 0.)
-_i = complex(0., 1.)
-_halfi = complex(0., 0.5)
-
-
-
-# internal functions not available from Python
-def _to_complex(x):
-    if isinstance(x, complex):
-        return x
-    if isinstance(x, (str, unicode)):
-        raise TypeError('float or complex required')
-    return complex(x)
-
-def _prodi(x):
-    x = _to_complex(x)
-    real = -x.imag
-    imag = x.real
-    return complex(real, imag)
-
-
- at builtinify
-def phase(x):
-    x = _to_complex(x)
-    return math.atan2(x.imag, x.real)
-
-
- at builtinify
-def polar(x):
-    x = _to_complex(x)
-    phi = math.atan2(x.imag, x.real)
-    r = abs(x)
-    return r, phi
-
-
- at builtinify
-def rect(r, phi):
-    return complex(r * math.cos(phi), r * math.sin(phi))
-
-
- at builtinify
-def acos(x):
-    """acos(x)
-
-    Return the arc cosine of x."""
-
-    x = _to_complex(x)
-    return -(_prodi(log((x+(_i*sqrt((_one-(x*x))))))))
-
-
- at builtinify
-def acosh(x):
-    """acosh(x)
-
-    Return the hyperbolic arccosine of x."""
-
-    x = _to_complex(x)
-    z = log(_sqrt_half*(sqrt(x+_one)+sqrt(x-_one)))
-    return z+z
-
-
- at builtinify
-def asin(x):
-    """asin(x)
-
-    Return the arc sine of x."""
-
-    x = _to_complex(x)
-    # -i * log[(sqrt(1-x**2) + i*x]
-    squared = x*x
-    sqrt_1_minus_x_sq = sqrt(_one-squared)
-    return -(_prodi(log((sqrt_1_minus_x_sq+_prodi(x)))))
-
-
- at builtinify
-def asinh(x):
-    """asinh(x)
-
-    Return the hyperbolic arc sine of x."""
-
-    x = _to_complex(x)
-    z = log((_sqrt_half * (sqrt(x+_i)+sqrt((x-_i))) ))
-    return z+z
-
-
- at builtinify
-def atan(x):
-    """atan(x)
-    
-    Return the arc tangent of x."""
-
-    x = _to_complex(x)
-    return _halfi*log(((_i+x)/(_i-x)))
-
-
- at builtinify
-def atanh(x):
-    """atanh(x)
-
-    Return the hyperbolic arc tangent of x."""
-
-    x = _to_complex(x)
-    return _half*log((_one+x)/(_one-x))
-
-
- at builtinify
-def cos(x):
-    """cos(x)
-
-    Return the cosine of x."""
-
-    x = _to_complex(x)
-    real = math.cos(x.real) * math.cosh(x.imag)
-    imag = -math.sin(x.real) * math.sinh(x.imag)
-    return complex(real, imag)
-
-
- at builtinify
-def cosh(x):
-    """cosh(x)
-    
-    Return the hyperbolic cosine of x."""
-
-    x = _to_complex(x)
-    real = math.cos(x.imag) * math.cosh(x.real)
-    imag = math.sin(x.imag) * math.sinh(x.real)
-    return complex(real, imag)
-
-
- at builtinify
-def exp(x):
-    """exp(x)
-    
-    Return the exponential value e**x."""
-
-    x = _to_complex(x)
-    l = math.exp(x.real)
-    real = l * math.cos(x.imag)
-    imag = l * math.sin(x.imag)
-    return complex(real, imag)
-
-
- at builtinify
-def log(x, base=None):
-    """log(x)
-
-    Return the natural logarithm of x."""
-    
-    if base is not None:
-        return log(x) / log(base)
-    x = _to_complex(x)
-    l = math.hypot(x.real,x.imag)
-    imag = math.atan2(x.imag, x.real)
-    real = math.log(l)
-    return complex(real, imag)
-
-
- at builtinify
-def log10(x):
-    """log10(x)
-
-    Return the base-10 logarithm of x."""
-    
-    x = _to_complex(x)
-    l = math.hypot(x.real, x.imag)
-    imag = math.atan2(x.imag, x.real)/math.log(10.)
-    real = math.log10(l)
-    return complex(real, imag)
-
-
- at builtinify
-def sin(x):
-    """sin(x)
-
-    Return the sine of x."""
-    
-    x = _to_complex(x)
-    real = math.sin(x.real) * math.cosh(x.imag)
-    imag = math.cos(x.real) * math.sinh(x.imag)
-    return complex(real, imag)
-
-
- at builtinify
-def sinh(x):
-    """sinh(x)
-
-    Return the hyperbolic sine of x."""
-    
-    x = _to_complex(x)
-    real = math.cos(x.imag) * math.sinh(x.real)
-    imag = math.sin(x.imag) * math.cosh(x.real)
-    return complex(real, imag)
-
-
- at builtinify
-def sqrt(x):
-    """sqrt(x)
-
-    Return the square root of x."""
-    
-    x = _to_complex(x)
-    if x.real == 0. and x.imag == 0.:
-        real, imag = 0, 0
-    else:
-        s = math.sqrt(0.5*(math.fabs(x.real) + math.hypot(x.real,x.imag)))
-        d = 0.5*x.imag/s
-        if x.real > 0.:
-            real = s
-            imag = d
-        elif x.imag >= 0.:
-            real = d
-            imag = s
-        else:
-            real = -d
-            imag = -s
-    return complex(real, imag)
-
-_sqrt_half = sqrt(_half)
-
-
- at builtinify
-def tan(x):
-    """tan(x)
-
-    Return the tangent of x."""
-
-    x = _to_complex(x)
-    sr = math.sin(x.real)
-    cr = math.cos(x.real)
-    shi = math.sinh(x.imag)
-    chi = math.cosh(x.imag)
-    rs = sr * chi
-    is_ = cr * shi
-    rc = cr * chi
-    ic = -sr * shi
-    d = rc*rc + ic * ic
-    real = (rs*rc + is_*ic) / d
-    imag = (is_*rc - rs*ic) / d
-    return complex(real, imag)
-
-
- at builtinify
-def tanh(x):
-    """tanh(x)
-
-    Return the hyperbolic tangent of x."""
-    
-    x = _to_complex(x)
-    si = math.sin(x.imag)
-    ci = math.cos(x.imag)
-    shr = math.sinh(x.real)
-    chr = math.cosh(x.real)
-    rs = ci * shr
-    is_ = si * chr
-    rc = ci * chr
-    ic = si * shr
-    d = rc*rc + ic*ic
-    real = (rs*rc + is_*ic) / d
-    imag = (is_*rc - rs*ic) / d
-    return complex(real, imag)
-
-def isnan(x):
-    """isnan(z) -> bool
-    Checks if the real or imaginary part of z not a number (NaN)"""
-    x = _to_complex(x)
-    return math.isnan(x.real) or math.isnan(x.imag)
-
-def isinf(x):
-    """isnan(z) -> bool
-    Checks if the real or imaginary part of z is infinite"""
-    x = _to_complex(x)
-    return math.isinf(x.real) or math.isinf(x.imag)

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -18,7 +18,7 @@
 default_modules = essential_modules.copy()
 default_modules.update(dict.fromkeys(
     ["_codecs", "gc", "_weakref", "marshal", "errno", "imp",
-     "math", "_sre", "_pickle_support", "operator",
+     "math", "cmath", "_sre", "_pickle_support", "operator",
      "parser", "symbol", "token", "_ast",  "_io", "_random", "__pypy__",
      "_testing"]))
 


More information about the Pypy-commit mailing list