[pypy-commit] pypy numpypy-out: merge from default

mattip noreply at buildbot.pypy.org
Mon Feb 13 00:57:53 CET 2012


Author: mattip
Branch: numpypy-out
Changeset: r52404:b945d10c4adf
Date: 2012-02-12 23:21 +0200
http://bitbucket.org/pypy/pypy/changeset/b945d10c4adf/

Log:	merge from default

diff --git a/ctypes_configure/cbuild.py b/ctypes_configure/cbuild.py
--- a/ctypes_configure/cbuild.py
+++ b/ctypes_configure/cbuild.py
@@ -206,8 +206,9 @@
     cfiles += eci.separate_module_files
     include_dirs = list(eci.include_dirs)
     library_dirs = list(eci.library_dirs)
-    if sys.platform == 'darwin':    # support Fink & Darwinports
-        for s in ('/sw/', '/opt/local/'):
+    if (sys.platform == 'darwin' or    # support Fink & Darwinports
+            sys.platform.startswith('freebsd')):
+        for s in ('/sw/', '/opt/local/', '/usr/local/'):
             if s + 'include' not in include_dirs and \
                os.path.exists(s + 'include'):
                 include_dirs.append(s + 'include')
@@ -380,9 +381,9 @@
             self.link_extra += ['-pthread']
         if sys.platform == 'win32':
             self.link_extra += ['/DEBUG'] # generate .pdb file
-        if sys.platform == 'darwin':
-            # support Fink & Darwinports
-            for s in ('/sw/', '/opt/local/'):
+        if (sys.platform == 'darwin' or    # support Fink & Darwinports
+                sys.platform.startswith('freebsd')):
+            for s in ('/sw/', '/opt/local/', '/usr/local/'):
                 if s + 'include' not in self.include_dirs and \
                    os.path.exists(s + 'include'):
                     self.include_dirs.append(s + 'include')
@@ -395,7 +396,6 @@
             self.outputfilename = py.path.local(cfilenames[0]).new(ext=ext)
         else: 
             self.outputfilename = py.path.local(outputfilename)
-        self.eci = eci
 
     def build(self, noerr=False):
         basename = self.outputfilename.new(ext='')
@@ -436,7 +436,7 @@
             old = cfile.dirpath().chdir() 
             try: 
                 res = compiler.compile([cfile.basename], 
-                                       include_dirs=self.eci.include_dirs,
+                                       include_dirs=self.include_dirs,
                                        extra_preargs=self.compile_extra)
                 assert len(res) == 1
                 cobjfile = py.path.local(res[0]) 
@@ -445,9 +445,9 @@
             finally: 
                 old.chdir() 
         compiler.link_executable(objects, str(self.outputfilename),
-                                 libraries=self.eci.libraries,
+                                 libraries=self.libraries,
                                  extra_preargs=self.link_extra,
-                                 library_dirs=self.eci.library_dirs)
+                                 library_dirs=self.library_dirs)
 
 def build_executable(*args, **kwds):
     noerr = kwds.pop('noerr', False)
diff --git a/lib-python/modified-2.7/UserDict.py b/lib-python/modified-2.7/UserDict.py
--- a/lib-python/modified-2.7/UserDict.py
+++ b/lib-python/modified-2.7/UserDict.py
@@ -85,8 +85,12 @@
     def __iter__(self):
         return iter(self.data)
 
-import _abcoll
-_abcoll.MutableMapping.register(IterableUserDict)
+try:
+    import _abcoll
+except ImportError:
+    pass    # e.g. no '_weakref' module on this pypy
+else:
+    _abcoll.MutableMapping.register(IterableUserDict)
 
 
 class DictMixin:
diff --git a/lib_pypy/_subprocess.py b/lib_pypy/_subprocess.py
--- a/lib_pypy/_subprocess.py
+++ b/lib_pypy/_subprocess.py
@@ -87,7 +87,7 @@
 
 # Now the _subprocess module implementation 
 
-from ctypes import c_int as _c_int, byref as _byref
+from ctypes import c_int as _c_int, byref as _byref, WinError as _WinError
 
 class _handle:
     def __init__(self, handle):
@@ -116,7 +116,7 @@
     res = _CreatePipe(_byref(read), _byref(write), None, size)
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return _handle(read.value), _handle(write.value)
 
@@ -132,7 +132,7 @@
                            access, inherit, options)
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return _handle(target.value)
 DUPLICATE_SAME_ACCESS = 2
@@ -165,7 +165,7 @@
                         start_dir, _byref(si), _byref(pi))
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID
 STARTF_USESHOWWINDOW = 0x001
@@ -178,7 +178,7 @@
     res = _WaitForSingleObject(int(handle), milliseconds)
 
     if res < 0:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return res
 INFINITE = 0xffffffff
@@ -190,7 +190,7 @@
     res = _GetExitCodeProcess(int(handle), _byref(code))
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return code.value
 
@@ -198,7 +198,7 @@
     res = _TerminateProcess(int(handle), exitcode)
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
 def GetStdHandle(stdhandle):
     res = _GetStdHandle(stdhandle)
diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -1520,7 +1520,7 @@
     def utcfromtimestamp(cls, t):
         "Construct a UTC datetime from a POSIX timestamp (like time.time())."
         t, frac = divmod(t, 1.0)
-        us = round(frac * 1e6)
+        us = int(round(frac * 1e6))
 
         # If timestamp is less than one microsecond smaller than a
         # full second, us can be rounded up to 1000000.  In this case,
diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -388,7 +388,9 @@
   In a few cases (e.g. hash table manipulation), we need machine-sized unsigned
   arithmetic.  For these cases there is the r_uint class, which is a pure
   Python implementation of word-sized unsigned integers that silently wrap
-  around.  The purpose of this class (as opposed to helper functions as above)
+  around.  ("word-sized" and "machine-sized" are used equivalently and mean
+  the native size, which you get using "unsigned long" in C.)
+  The purpose of this class (as opposed to helper functions as above)
   is consistent typing: both Python and the annotator will propagate r_uint
   instances in the program and interpret all the operations between them as
   unsigned.  Instances of r_uint are special-cased by the code generators to
diff --git a/pypy/doc/getting-started-python.rst b/pypy/doc/getting-started-python.rst
--- a/pypy/doc/getting-started-python.rst
+++ b/pypy/doc/getting-started-python.rst
@@ -103,18 +103,22 @@
 executable. The executable behaves mostly like a normal Python interpreter::
 
     $ ./pypy-c
-    Python 2.7.0 (61ef2a11b56a, Mar 02 2011, 03:00:11)
-    [PyPy 1.6.0 with GCC 4.4.3] on linux2
+    Python 2.7.2 (0e28b379d8b3, Feb 09 2012, 19:41:03)
+    [PyPy 1.8.0 with GCC 4.4.3] on linux2
     Type "help", "copyright", "credits" or "license" for more information.
     And now for something completely different: ``this sentence is false''
     >>>> 46 - 4
     42
     >>>> from test import pystone
     >>>> pystone.main()
-    Pystone(1.1) time for 50000 passes = 0.280017
-    This machine benchmarks at 178561 pystones/second
-    >>>>
+    Pystone(1.1) time for 50000 passes = 0.220015
+    This machine benchmarks at 227257 pystones/second
+    >>>> pystone.main()
+    Pystone(1.1) time for 50000 passes = 0.060004
+    This machine benchmarks at 833278 pystones/second
+    >>>> 
 
+Note that pystone gets faster as the JIT kicks in.
 This executable can be moved around or copied on other machines; see
 Installation_ below.
 
diff --git a/pypy/doc/getting-started.rst b/pypy/doc/getting-started.rst
--- a/pypy/doc/getting-started.rst
+++ b/pypy/doc/getting-started.rst
@@ -55,11 +55,13 @@
 
     $ tar xf pypy-1.8-linux.tar.bz2
     $ ./pypy-1.8/bin/pypy
-    Python 2.7.1 (48ebdce33e1b, Feb 09 2012, 00:55:31)
+    Python 2.7.2 (0e28b379d8b3, Feb 09 2012, 19:41:03)
     [PyPy 1.8.0 with GCC 4.4.3] on linux2
     Type "help", "copyright", "credits" or "license" for more information.
-    And now for something completely different: ``implementing LOGO in LOGO:
-    "turtles all the way down"''
+    And now for something completely different: ``it seems to me that once you
+    settle on an execution / object model and / or bytecode format, you've already
+    decided what languages (where the 's' seems superfluous) support is going to be
+    first class for''
     >>>>
 
 If you want to make PyPy available system-wide, you can put a symlink to the
diff --git a/pypy/doc/release-1.8.0.rst b/pypy/doc/release-1.8.0.rst
--- a/pypy/doc/release-1.8.0.rst
+++ b/pypy/doc/release-1.8.0.rst
@@ -3,13 +3,15 @@
 ============================
 
 We're pleased to announce the 1.8 release of PyPy. As habitual this
-release brings a lot of bugfixes, together with performance and memory improvements over
-the 1.7 release. The main highlight of the release is the introduction of
-`list strategies`_ which makes homogenous lists more efficient both in terms
-of performance and memory. This release also upgrades us from Python 2.7.1 compatibility to 2.7.2. Otherwise it's "business as usual" in the sense
-that performance improved roughly 10% on average since the previous release.
+release brings a lot of bugfixes, together with performance and memory
+improvements over the 1.7 release. The main highlight of the release
+is the introduction of `list strategies`_ which makes homogenous lists
+more efficient both in terms of performance and memory. This release
+also upgrades us from Python 2.7.1 compatibility to 2.7.2. Otherwise
+it's "business as usual" in the sense that performance improved
+roughly 10% on average since the previous release.
 
-You can download the PyPy 1.8 release here:
+you can download the PyPy 1.8 release here:
 
     http://pypy.org/download.html
 
@@ -85,6 +87,9 @@
 * It's also probably worth noting, we're considering donations for the
   Software Transactional Memory project. You can read more about `our plans`_
 
+Cheers,
+The PyPy Team
+
 .. _`brief overview`: http://doc.pypy.org/en/latest/jit-hooks.html
 .. _`numpy status page`: http://buildbot.pypy.org/numpy-status/latest.html
 .. _`numpy status update blog report`: http://morepypy.blogspot.com/2012/01/numpypy-status-update.html
diff --git a/pypy/module/_io/test/test_fileio.py b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -134,7 +134,10 @@
         assert a == 'a\nbxxxxxxx'
 
     def test_nonblocking_read(self):
-        import os, fcntl
+        try:
+            import os, fcntl
+        except ImportError:
+            skip("need fcntl to set nonblocking mode")
         r_fd, w_fd = os.pipe()
         # set nonblocking
         fcntl.fcntl(r_fd, fcntl.F_SETFL, os.O_NONBLOCK)
diff --git a/pypy/module/cpyext/include/patchlevel.h b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -21,12 +21,12 @@
 /* Version parsed out into numeric values */
 #define PY_MAJOR_VERSION	2
 #define PY_MINOR_VERSION	7
-#define PY_MICRO_VERSION	1
+#define PY_MICRO_VERSION	2
 #define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_FINAL
 #define PY_RELEASE_SERIAL	0
 
 /* Version as a string */
-#define PY_VERSION		"2.7.1"
+#define PY_VERSION		"2.7.2"
 
 /* PyPy version as a string */
 #define PYPY_VERSION "1.8.1"
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -95,6 +95,7 @@
         ("tan", "tan"),
         ('bitwise_and', 'bitwise_and'),
         ('bitwise_or', 'bitwise_or'),
+        ('bitwise_xor', 'bitwise_xor'),
         ('bitwise_not', 'invert'),
         ('isnan', 'isnan'),
         ('isinf', 'isinf'),
diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -100,6 +100,7 @@
     descr_rsub = _binop_right_impl("subtract")
     descr_rmul = _binop_right_impl("multiply")
     descr_rdiv = _binop_right_impl("divide")
+    descr_rtruediv = _binop_right_impl("true_divide")
     descr_rmod = _binop_right_impl("mod")
     descr_rpow = _binop_right_impl("power")
     descr_rlshift = _binop_right_impl("left_shift")
@@ -216,6 +217,7 @@
     __rsub__ = interp2app(W_GenericBox.descr_rsub),
     __rmul__ = interp2app(W_GenericBox.descr_rmul),
     __rdiv__ = interp2app(W_GenericBox.descr_rdiv),
+    __rtruediv__ = interp2app(W_GenericBox.descr_rtruediv),
     __rmod__ = interp2app(W_GenericBox.descr_rmod),
     __rdivmod__ = interp2app(W_GenericBox.descr_rdivmod),
     __rpow__ = interp2app(W_GenericBox.descr_rpow),
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -4,17 +4,17 @@
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.module.micronumpy import (interp_ufuncs, interp_dtype, interp_boxes,
     signature, support, loop)
+from pypy.module.micronumpy.appbridge import get_appbridge_cache
+from pypy.module.micronumpy.dot import multidim_dot, match_dot_shapes
+from pypy.module.micronumpy.interp_iter import (ArrayIterator,
+    SkipLastAxisIterator, Chunk, ViewIterator)
 from pypy.module.micronumpy.strides import (calculate_slice_strides,
     shape_agreement, find_shape_and_elems, get_shape_from_iterable,
     calc_new_strides, to_coords)
-from dot import multidim_dot, match_dot_shapes
 from pypy.rlib import jit
+from pypy.rlib.rstring import StringBuilder
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.tool.sourcetools import func_with_new_name
-from pypy.rlib.rstring import StringBuilder
-from pypy.module.micronumpy.interp_iter import (ArrayIterator,
-    SkipLastAxisIterator, Chunk, ViewIterator)
-from pypy.module.micronumpy.appbridge import get_appbridge_cache
 
 
 count_driver = jit.JitDriver(
@@ -101,6 +101,7 @@
     descr_sub = _binop_impl("subtract")
     descr_mul = _binop_impl("multiply")
     descr_div = _binop_impl("divide")
+    descr_truediv = _binop_impl("true_divide")
     descr_mod = _binop_impl("mod")
     descr_pow = _binop_impl("power")
     descr_lshift = _binop_impl("left_shift")
@@ -134,6 +135,7 @@
     descr_rsub = _binop_right_impl("subtract")
     descr_rmul = _binop_right_impl("multiply")
     descr_rdiv = _binop_right_impl("divide")
+    descr_rtruediv = _binop_right_impl("true_divide")
     descr_rmod = _binop_right_impl("mod")
     descr_rpow = _binop_right_impl("power")
     descr_rlshift = _binop_right_impl("left_shift")
@@ -1258,6 +1260,7 @@
     __sub__ = interp2app(BaseArray.descr_sub),
     __mul__ = interp2app(BaseArray.descr_mul),
     __div__ = interp2app(BaseArray.descr_div),
+    __truediv__ = interp2app(BaseArray.descr_truediv),
     __mod__ = interp2app(BaseArray.descr_mod),
     __divmod__ = interp2app(BaseArray.descr_divmod),
     __pow__ = interp2app(BaseArray.descr_pow),
@@ -1271,6 +1274,7 @@
     __rsub__ = interp2app(BaseArray.descr_rsub),
     __rmul__ = interp2app(BaseArray.descr_rmul),
     __rdiv__ = interp2app(BaseArray.descr_rdiv),
+    __rtruediv__ = interp2app(BaseArray.descr_rtruediv),
     __rmod__ = interp2app(BaseArray.descr_rmod),
     __rdivmod__ = interp2app(BaseArray.descr_rdivmod),
     __rpow__ = interp2app(BaseArray.descr_rpow),
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -408,6 +408,7 @@
 
         assert 5 / int_(2) == int_(2)
         assert truediv(int_(3), int_(2)) == float64(1.5)
+        assert truediv(3, int_(2)) == float64(1.5)
         assert int_(8) % int_(3) == int_(2)
         assert 8 % int_(3) == int_(2)
         assert divmod(int_(8), int_(3)) == (int_(2), int_(2))
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -625,6 +625,13 @@
         for i in range(5):
             assert b[i] == i / 5.0
 
+    def test_truediv(self):
+        from operator import truediv
+        from _numpypy import arange
+
+        assert (truediv(arange(5), 2) == [0., .5, 1., 1.5, 2.]).all()
+        assert (truediv(2, arange(3)) == [float("inf"), 2., 1.]).all()
+
     def test_divmod(self):
         from _numpypy import arange
 
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -368,14 +368,14 @@
         assert b.shape == (1, 4)
         assert (add.reduce(a, 0, keepdims=True) == [12, 15, 18, 21]).all()
 
-
     def test_bitwise(self):
-        from _numpypy import bitwise_and, bitwise_or, arange, array
+        from _numpypy import bitwise_and, bitwise_or, bitwise_xor, arange, array
         a = arange(6).reshape(2, 3)
         assert (a & 1 == [[0, 1, 0], [1, 0, 1]]).all()
         assert (a & 1 == bitwise_and(a, 1)).all()
         assert (a | 1 == [[1, 1, 3], [3, 5, 5]]).all()
         assert (a | 1 == bitwise_or(a, 1)).all()
+        assert (a ^ 3 == bitwise_xor(a, 3)).all()
         raises(TypeError, 'array([1.0]) & 1')
 
     def test_unary_bitops(self):
diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py
--- a/pypy/module/pypyjit/__init__.py
+++ b/pypy/module/pypyjit/__init__.py
@@ -13,6 +13,7 @@
         'ResOperation': 'interp_resop.WrappedOp',
         'DebugMergePoint': 'interp_resop.DebugMergePoint',
         'Box': 'interp_resop.WrappedBox',
+        'PARAMETER_DOCS': 'space.wrap(pypy.rlib.jit.PARAMETER_DOCS)',
     }
 
     def setup_after_space_initialization(self):
diff --git a/pypy/module/pypyjit/test/test_jit_setup.py b/pypy/module/pypyjit/test/test_jit_setup.py
--- a/pypy/module/pypyjit/test/test_jit_setup.py
+++ b/pypy/module/pypyjit/test/test_jit_setup.py
@@ -45,6 +45,12 @@
             pypyjit.set_compile_hook(None)
             pypyjit.set_param('default')
 
+    def test_doc(self):
+        import pypyjit
+        d = pypyjit.PARAMETER_DOCS
+        assert type(d) is dict
+        assert 'threshold' in d
+
 
 def test_interface_residual_call():
     space = gettestobjspace(usemodules=['pypyjit'])
diff --git a/pypy/module/test_lib_pypy/test_datetime.py b/pypy/module/test_lib_pypy/test_datetime.py
--- a/pypy/module/test_lib_pypy/test_datetime.py
+++ b/pypy/module/test_lib_pypy/test_datetime.py
@@ -22,3 +22,7 @@
             del os.environ["TZ"]
         else:
             os.environ["TZ"] = prev_tz
+
+def test_utcfromtimestamp_microsecond():
+    dt = datetime.datetime.utcfromtimestamp(0)
+    assert isinstance(dt.microsecond, int)
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -126,7 +126,7 @@
             zf.close()
         else:
             archive = str(builddir.join(name + '.tar.bz2'))
-            if sys.platform == 'darwin':
+            if sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
                 e = os.system('tar --numeric-owner -cvjf ' + archive + " " + name)
             else:
                 e = os.system('tar --owner=root --group=root --numeric-owner -cvjf ' + archive + " " + name)
diff --git a/pypy/translator/c/gcc/trackgcroot.py b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -478,6 +478,7 @@
         'cvt', 'ucomi', 'comi', 'subs', 'subp' , 'adds', 'addp', 'xorp',
         'movap', 'movd', 'movlp', 'sqrtsd', 'movhpd',
         'mins', 'minp', 'maxs', 'maxp', 'unpck', 'pxor', 'por', # sse2
+        'shufps', 'shufpd',
         # arithmetic operations should not produce GC pointers
         'inc', 'dec', 'not', 'neg', 'or', 'and', 'sbb', 'adc',
         'shl', 'shr', 'sal', 'sar', 'rol', 'ror', 'mul', 'imul', 'div', 'idiv',
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -139,8 +139,14 @@
     items = pypyjit.defaults.items()
     items.sort()
     for key, value in items:
-        print '  --jit %s=N %s%s (default %s)' % (
-            key, ' '*(18-len(key)), pypyjit.PARAMETER_DOCS[key], value)
+        prefix = '  --jit %s=N %s' % (key, ' '*(18-len(key)))
+        doc = '%s (default %s)' % (pypyjit.PARAMETER_DOCS[key], value)
+        while len(doc) > 51:
+            i = doc[:51].rfind(' ')
+            print prefix + doc[:i]
+            doc = doc[i+1:]
+            prefix = ' '*len(prefix)
+        print prefix + doc
     print '  --jit off                  turn off the JIT'
 
 def print_version(*args):


More information about the pypy-commit mailing list