[pypy-commit] benchmarks default: fixes
Author: Armin Rigo Branch: Changeset: r293:24b6c21ba3f0 Date: 2014-12-10 09:27 + http://bitbucket.org/pypy/benchmarks/changeset/24b6c21ba3f0/ Log:fixes diff --git a/own/bm_icbd.py b/own/bm_icbd.py --- a/own/bm_icbd.py +++ b/own/bm_icbd.py @@ -3,26 +3,33 @@ def main(n): # HAACK with subprocess because I can't get the thing -# to run in-process :-( As a result, it doesn't make -# sense to run it more than once. - -d = os.environ.copy() -d['PYTHONPATH'] = 'icbd' -t0 = time.time() -popen = subprocess.Popen( - [sys.executable, - '-m', 'icbd.type_analyzer.analyze_all', - '-I', 'stdlib/python2.5_tiny', - '-I', '.', - '-E', 'icbd/type_analyzer/tests', - '-E', 'icbd/compiler/benchmarks', - '-E', 'icbd/compiler/tests', - '-I', 'stdlib/type_mocks', - '-n', - 'icbd'], cwd=this_dir, env=d, stdout=subprocess.PIPE) -popen.communicate() -time_elapsed = time.time() - t0 -return [time_elapsed] * n +# to run in-process :-( As a result, it doesn't make much +# sense to run it more than once. We'll run it n/25 times, +# like hexiom2. All runs suffer from warm-up. +l = [] +for i in range(n): +if (i % 25) == 0: +d = os.environ.copy() +d['PYTHONPATH'] = 'icbd' +t0 = time.time() +popen = subprocess.Popen( + [sys.executable, + '-m', 'icbd.type_analyzer.analyze_all', + '-I', 'stdlib/python2.5_tiny', + '-I', '.', + '-E', 'icbd/type_analyzer/tests', + '-E', 'icbd/compiler/benchmarks', + '-E', 'icbd/compiler/tests', + '-I', 'stdlib/type_mocks', + '-n', + 'icbd'], + cwd=this_dir, env=d, stdout=subprocess.PIPE) +popen.communicate() +if popen.returncode != 0: +raise OSError("the subprocess failed, see above") +time_elapsed = time.time() - t0 +l.append(time_elapsed) +return l if __name__ == "__main__": import util, optparse ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: Add ICBD as a benchmark. This comes from Kevin Modzelewski on pypy-dev.
Author: Armin Rigo Branch: Changeset: r292:67706c915134 Date: 2014-12-10 09:15 + http://bitbucket.org/pypy/benchmarks/changeset/67706c915134/ Log:Add ICBD as a benchmark. This comes from Kevin Modzelewski on pypy- dev. diff too long, truncating to 2000 out of 90238 lines diff --git a/benchmarks.py b/benchmarks.py --- a/benchmarks.py +++ b/benchmarks.py @@ -82,7 +82,8 @@ 'spectral-norm', 'chaos', 'telco', 'go', 'pyflate-fast', 'raytrace-simple', 'crypto_pyaes', 'bm_mako', 'bm_chameleon', 'json_bench', 'pidigits', 'hexiom2', 'eparse', 'deltablue', - 'bm_dulwich_log', 'bm_krakatau', 'bm_mdp', 'pypy_interp']: + 'bm_dulwich_log', 'bm_krakatau', 'bm_mdp', 'pypy_interp', + 'bm_icbd']: _register_new_bm(name, name, globals(), **opts.get(name, {})) for name in ['names', 'iteration', 'tcp', 'pb', ]:#'web']:#, 'accepts']: diff --git a/own/bm_icbd.py b/own/bm_icbd.py new file mode 100644 --- /dev/null +++ b/own/bm_icbd.py @@ -0,0 +1,35 @@ +import sys, os, subprocess, time +this_dir = os.path.abspath(os.path.dirname(__file__)) + +def main(n): +# HAACK with subprocess because I can't get the thing +# to run in-process :-( As a result, it doesn't make +# sense to run it more than once. + +d = os.environ.copy() +d['PYTHONPATH'] = 'icbd' +t0 = time.time() +popen = subprocess.Popen( + [sys.executable, + '-m', 'icbd.type_analyzer.analyze_all', + '-I', 'stdlib/python2.5_tiny', + '-I', '.', + '-E', 'icbd/type_analyzer/tests', + '-E', 'icbd/compiler/benchmarks', + '-E', 'icbd/compiler/tests', + '-I', 'stdlib/type_mocks', + '-n', + 'icbd'], cwd=this_dir, env=d, stdout=subprocess.PIPE) +popen.communicate() +time_elapsed = time.time() - t0 +return [time_elapsed] * n + +if __name__ == "__main__": +import util, optparse +parser = optparse.OptionParser( +usage="%prog [options]", +description="Test the performance of the ICBD benchmark") +util.add_standard_options_to(parser) +options, args = parser.parse_args() + +util.run_benchmark(options, options.num_runs, main) diff --git a/own/icbd/.gitignore b/own/icbd/.gitignore new file mode 100644 --- /dev/null +++ b/own/icbd/.gitignore @@ -0,0 +1,24 @@ +*.pyc +*.d +*.sw? +*.out +*.out[0-9] +*.o +*.s +*.s[0-9] +*.gen.bc +*.gen.c +*.comb.ll +*.gen.ll +*opt.ll +*.so +icbd/compiler/tests/[0-9] +icbd/compiler/tests/[0-9][0-9] +icbd/compiler/tests/*.hpp +icbd/compiler/tests/*[0-9].cpp +icbd/compiler/tests/Makefile +*.shed +*.ppm +icbd/compiler/dist +*.pyicbd +*.pyd diff --git a/own/icbd/LICENSE b/own/icbd/LICENSE new file mode 100644 --- /dev/null +++ b/own/icbd/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014, Kevin Modzelewski + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/own/icbd/README.md b/own/icbd/README.md new file mode 100644 --- /dev/null +++ b/own/icbd/README.md @@ -0,0 +1,109 @@ +# icbd + +> ICBD is a defunct project, but I'm releasing the source code in case any one is interested. + +ICBD is a static type analyzer and static compiler for Python. It originated +from the desire at Dropbox to have additional type information for our growing +codebases, without requiring programmers to add type annotations. There are +other static type analyzers for Python out there; the goal of ICBD was to +produce one that would work well on the Dropbox codebase, which meant +concretely: + +- Handling untypable code as gracefully as possible +- "Acceptable" running times for multi-100k LOC codebases +- A plugin system for handling code that is inherently not statically analyzable + +These goals were somewhat met, perhaps to the limits of using whole-program type +inference; the running time for the Dr
[pypy-commit] pypy default: Try to clean up the construction of GcStructs with inlined fields.
Author: Armin Rigo Branch: Changeset: r74876:1a2817c44b28 Date: 2014-12-10 11:16 + http://bitbucket.org/pypy/pypy/changeset/1a2817c44b28/ Log:Try to clean up the construction of GcStructs with inlined fields. Complains e.g. on GcStructs containing inlined no-length arrays. diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py --- a/rpython/rtyper/lltypesystem/lltype.py +++ b/rpython/rtyper/lltypesystem/lltype.py @@ -182,8 +182,8 @@ def _freeze_(self): return True -def _inline_is_varsize(self, last): -return False +def _note_inlined_into(self, parent, first, last): +"""Called when this type is being used inline in a container.""" def _is_atomic(self): return False @@ -201,8 +201,9 @@ class ContainerType(LowLevelType): _adtmeths = {} -def _inline_is_varsize(self, last): -raise TypeError("%r cannot be inlined in structure" % self) +def _note_inlined_into(self, parent, first, last): +raise TypeError("%r cannot be inlined in %r" % ( +self.__class__.__name__, parent.__class__.__name__)) def _install_extras(self, adtmeths={}, hints={}): self._adtmeths = frozendict(adtmeths) @@ -279,11 +280,13 @@ # look if we have an inlined variable-sized array as the last field if fields: +first = True for name, typ in fields[:-1]: -typ._inline_is_varsize(False) +typ._note_inlined_into(self, first=first, last=False) first = False name, typ = fields[-1] -if typ._inline_is_varsize(True): +typ._note_inlined_into(self, first=first, last=True) +if typ._is_varsize(): self._arrayfld = name self._flds = frozendict(flds) self._names = tuple(names) @@ -299,11 +302,14 @@ return first, FIRSTTYPE return None, None -def _inline_is_varsize(self, last): -if self._arrayfld: +def _note_inlined_into(self, parent, first, last): +if self._arrayfld is not None: raise TypeError("cannot inline a var-sized struct " "inside another container") -return False +if self._gckind == 'gc': +if not first or not isinstance(parent, GcStruct): +raise TypeError("a GcStruct can only be inlined as the first " +"field of another GcStruct") def _is_atomic(self): for typ in self._flds.values(): @@ -428,15 +434,18 @@ if isinstance(self.OF, ContainerType) and self.OF._gckind != 'raw': raise TypeError("cannot have a %s container as array item type" % (self.OF._gckind,)) -self.OF._inline_is_varsize(False) +self.OF._note_inlined_into(self, first=False, last=False) self._install_extras(**kwds) -def _inline_is_varsize(self, last): -if not last: +def _note_inlined_into(self, parent, first, last): +if not last or not isinstance(parent, Struct): raise TypeError("cannot inline an array in another container" " unless as the last field of a structure") -return True +if self._gckind == 'gc': +raise TypeError("cannot inline a GC array inside a structure") +if parent._gckind == 'gc' and self._hints.get('nolength', False): +raise TypeError("cannot inline a no-length array inside a GcStruct") def _is_atomic(self): return self.OF._is_atomic() @@ -474,9 +483,6 @@ class GcArray(Array): _gckind = 'gc' -def _inline_is_varsize(self, last): -raise TypeError("cannot inline a GC array inside a structure") - class FixedSizeArray(Struct): # behaves more or less like a Struct with fields item0, item1, ... @@ -508,7 +514,7 @@ if isinstance(self.OF, ContainerType) and self.OF._gckind != 'raw': raise TypeError("cannot have a %s container as array item type" % (self.OF._gckind,)) -self.OF._inline_is_varsize(False) +self.OF._note_inlined_into(self, first=False, last=False) def _str_fields(self): return str(self.OF) @@ -579,8 +585,11 @@ def __str__(self): return "%s (opaque)" % self.tag -def _inline_is_varsize(self, last): -return False# OpaqueType can be inlined +def _note_inlined_into(self, parent, first, last): +# OpaqueType can be inlined, but not GcOpaqueType +if self._gckind == 'gc': +raise TypeError("%r cannot be inlined in %r" % ( +self.__class__.__name__, parent.__class__.__name__)) def _container_example(self): return _opaque(self) @@ -599,10 +608,6 @@ def __str__(self): return "%s (gcopaque)" % self.tag -def _inline_is_varsize(self, last)
[pypy-commit] pypy vmprof: hg merge default
Author: Antonio Cuni Branch: vmprof Changeset: r74877:b53169916578 Date: 2014-12-10 14:26 + http://bitbucket.org/pypy/pypy/changeset/b53169916578/ Log:hg merge default diff too long, truncating to 2000 out of 52817 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -89,6 +89,7 @@ ^pypy/doc/image/lattice3\.png$ ^pypy/doc/image/stackless_informal\.png$ ^pypy/doc/image/parsing_example.+\.png$ +^rpython/doc/_build/.*$ ^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$ ^compiled ^.git/ diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -23,6 +23,7 @@ the pypy-dev team + Building @@ -36,4 +37,4 @@ to use virtualenv with the resulting pypy-c as the interpreter; you can find more details about various installation schemes here: -http://doc.pypy.org/en/latest/getting-started.html#installing-pypy +http://doc.pypy.org/en/latest/install.html diff --git a/ctypes_configure/doc/configure.txt b/ctypes_configure/doc/configure.txt --- a/ctypes_configure/doc/configure.txt +++ b/ctypes_configure/doc/configure.txt @@ -19,6 +19,4 @@ usage = -`sample.py`_ explains in details how to use it. - -.. _`sample.py`: http://codespeak.net/svn/pypy/dist/ctypes_configure/doc/sample.py +:source:`sample.py ` explains in details how to use it. diff --git a/lib-python/2.7/subprocess.py b/lib-python/2.7/subprocess.py --- a/lib-python/2.7/subprocess.py +++ b/lib-python/2.7/subprocess.py @@ -655,6 +655,21 @@ """Create new Popen instance.""" _cleanup() +# --- PyPy hack, see _pypy_install_libs_after_virtualenv() --- +# match arguments passed by different versions of virtualenv +if args[1:] in ( +['-c', 'import sys; print(sys.prefix)'],# 1.6 10ba3f3c +['-c', "\nimport sys\nprefix = sys.prefix\n"# 1.7 0e9342ce + "if sys.version_info[0] == 3:\n" + "prefix = prefix.encode('utf8')\n" + "if hasattr(sys.stdout, 'detach'):\n" + "sys.stdout = sys.stdout.detach()\n" + "elif hasattr(sys.stdout, 'buffer'):\n" + "sys.stdout = sys.stdout.buffer\nsys.stdout.write(prefix)\n"], +['-c', 'import sys;out=sys.stdout;getattr(out, "buffer"' + ', out).write(sys.prefix.encode("utf-8"))']): # 1.7.2 a9454bce +_pypy_install_libs_after_virtualenv(args[0]) + if not isinstance(bufsize, (int, long)): raise TypeError("bufsize must be an integer") @@ -1560,6 +1575,27 @@ self.send_signal(signal.SIGKILL) +def _pypy_install_libs_after_virtualenv(target_executable): +# https://bitbucket.org/pypy/pypy/issue/1922/future-proofing-virtualenv +# +# PyPy 2.4.1 turned --shared on by default. This means the pypy binary +# depends on the 'libpypy-c.so' shared library to be able to run. +# The virtualenv code existing at the time did not account for this +# and would break. Try to detect that we're running under such a +# virtualenv in the "Testing executable with" phase and copy the +# library ourselves. +caller = sys._getframe(2) +if ('virtualenv_version' in caller.f_globals and + 'copyfile' in caller.f_globals): +dest_dir = sys.pypy_resolvedirof(target_executable) +src_dir = sys.pypy_resolvedirof(sys.executable) +for libname in ['libpypy-c.so']: +dest_library = os.path.join(dest_dir, libname) +src_library = os.path.join(src_dir, libname) +if os.path.exists(src_library): +caller.f_globals['copyfile'](src_library, dest_library) + + def _demo_posix(): # # Example 1: Simple redirection: Get process list diff --git a/lib-python/conftest.py b/lib-python/conftest.py --- a/lib-python/conftest.py +++ b/lib-python/conftest.py @@ -59,7 +59,7 @@ def __init__(self, basename, core=False, compiler=None, usemodules='', skip=None): self.basename = basename -self._usemodules = usemodules.split() + ['signal', 'rctime', 'itertools', '_socket'] +self._usemodules = usemodules.split() + ['signal', 'time', 'itertools', '_socket'] self._compiler = compiler self.core = core self.skip = skip diff --git a/lib_pypy/grp.py b/lib_pypy/grp.py --- a/lib_pypy/grp.py +++ b/lib_pypy/grp.py @@ -66,11 +66,12 @@ @builtinify def getgrnam(name): -if not isinstance(name, str): +if not isinstance(name, basestring): raise TypeError("expected string") +name = str(name) res = libc.getgrnam(name) if not res: -raise KeyError(name) +raise KeyError("'getgrnam(): name not found: %s'" % name) return _group_from_gstruct(res) @builtinify diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -29,7 +29,7 @@ # --allworkingmodules working_modu
[pypy-commit] pypy default: (cfbolz, tanzim, arigo)
Author: Armin Rigo Branch: Changeset: r74878:e56dfa6f9309 Date: 2014-12-10 15:32 + http://bitbucket.org/pypy/pypy/changeset/e56dfa6f9309/ Log:(cfbolz, tanzim, arigo) Essential optimization (<=cfbolz). diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -17,9 +17,13 @@ self.w_value = w_value +def needs_to_unwrap_cell(space, w_value): +return (space.config.objspace.std.withtypeversion and +isinstance(w_value, TypeCell)) + + def unwrap_cell(space, w_value): -if (space.config.objspace.std.withtypeversion and -isinstance(w_value, TypeCell)): +if needs_to_unwrap_cell(space, w_value): return w_value.w_value return w_value @@ -366,8 +370,11 @@ tup = w_self._lookup_where(name) return tup name = promote_string(name) -w_class, w_value = w_self._pure_lookup_where_with_method_cache(name, version_tag) -return w_class, unwrap_cell(space, w_value) +tup_w = w_self._pure_lookup_where_with_method_cache(name, version_tag) +w_class, w_value = tup_w +if needs_to_unwrap_cell(space, w_value): +return w_class, w_value.value +return tup_w # don't make a new tuple, reuse the old one def _pure_lookup_where_possibly_with_method_cache(w_self, name, version_tag): if w_self.space.config.objspace.std.withmethodcache: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski Branch: Changeset: r74882:db19352f7582 Date: 2014-12-10 17:46 +0200 http://bitbucket.org/pypy/pypy/changeset/db19352f7582/ Log:merge diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py b/pypy/module/_rawffi/alt/interp_funcptr.py --- a/pypy/module/_rawffi/alt/interp_funcptr.py +++ b/pypy/module/_rawffi/alt/interp_funcptr.py @@ -14,6 +14,7 @@ from rpython.rlib.objectmodel import we_are_translated from pypy.module._rawffi.alt.type_converter import FromAppLevelConverter, ToAppLevelConverter from pypy.module._rawffi.interp_rawffi import got_libffi_error, wrap_dlopenerror +from pypy.module._rawffi import lasterror import os if os.name == 'nt': @@ -201,11 +202,23 @@ self.func = func self.argchain = argchain +def before(self): +lasterror.restore_last_error(self.space) + +def after(self): +lasterror.save_last_error(self.space) + def get_longlong(self, w_ffitype): -return self.func.call(self.argchain, rffi.LONGLONG) +self.before() +x = self.func.call(self.argchain, rffi.LONGLONG) +self.after() +return x def get_ulonglong(self, w_ffitype): -return self.func.call(self.argchain, rffi.ULONGLONG) +self.before() +x = self.func.call(self.argchain, rffi.ULONGLONG) +self.after() +return x def get_signed(self, w_ffitype): # if the declared return type of the function is smaller than LONG, @@ -216,64 +229,94 @@ # to space.wrap in order to get a nice applevel . # restype = w_ffitype.get_ffitype() +self.before() call = self.func.call if restype is libffi.types.slong: -return call(self.argchain, rffi.LONG) +x = call(self.argchain, rffi.LONG) elif restype is libffi.types.sint: -return rffi.cast(rffi.LONG, call(self.argchain, rffi.INT)) +x = rffi.cast(rffi.LONG, call(self.argchain, rffi.INT)) elif restype is libffi.types.sshort: -return rffi.cast(rffi.LONG, call(self.argchain, rffi.SHORT)) +x = rffi.cast(rffi.LONG, call(self.argchain, rffi.SHORT)) elif restype is libffi.types.schar: -return rffi.cast(rffi.LONG, call(self.argchain, rffi.SIGNEDCHAR)) +x = rffi.cast(rffi.LONG, call(self.argchain, rffi.SIGNEDCHAR)) else: -self.error(w_ffitype) +raise self.error(w_ffitype) +self.after() +return x def get_unsigned(self, w_ffitype): -return self.func.call(self.argchain, rffi.ULONG) +self.before() +x = self.func.call(self.argchain, rffi.ULONG) +self.after() +return x def get_unsigned_which_fits_into_a_signed(self, w_ffitype): # the same comment as get_signed apply restype = w_ffitype.get_ffitype() +self.before() call = self.func.call if restype is libffi.types.uint: assert not libffi.IS_32_BIT # on 32bit machines, we should never get here, because it's a case # which has already been handled by get_unsigned above. -return rffi.cast(rffi.LONG, call(self.argchain, rffi.UINT)) +x = rffi.cast(rffi.LONG, call(self.argchain, rffi.UINT)) elif restype is libffi.types.ushort: -return rffi.cast(rffi.LONG, call(self.argchain, rffi.USHORT)) +x = rffi.cast(rffi.LONG, call(self.argchain, rffi.USHORT)) elif restype is libffi.types.uchar: -return rffi.cast(rffi.LONG, call(self.argchain, rffi.UCHAR)) +x = rffi.cast(rffi.LONG, call(self.argchain, rffi.UCHAR)) else: -self.error(w_ffitype) +raise self.error(w_ffitype) +self.after() +return x def get_pointer(self, w_ffitype): +self.before() ptrres = self.func.call(self.argchain, rffi.VOIDP) +self.after() return rffi.cast(rffi.ULONG, ptrres) def get_char(self, w_ffitype): -return self.func.call(self.argchain, rffi.UCHAR) +self.before() +x = self.func.call(self.argchain, rffi.UCHAR) +self.after() +return x def get_unichar(self, w_ffitype): -return self.func.call(self.argchain, rffi.WCHAR_T) +self.before() +x = self.func.call(self.argchain, rffi.WCHAR_T) +self.after() +return x def get_float(self, w_ffitype): -return self.func.call(self.argchain, rffi.DOUBLE) +self.before() +x = self.func.call(self.argchain, rffi.DOUBLE) +self.after() +return x def get_singlefloat(self, w_ffitype): -return self.func.call(self.argchain, rffi.FLOAT) +self.before() +x = self.func.call(self.argchain, rffi.FLOAT) +self.after() +return x def get_struct(self, w_ffitype, w_structdescr): +self.before()
[pypy-commit] pypy object-dtype: small progress
Author: Maciej Fijalkowski Branch: object-dtype Changeset: r74879:8471e5574836 Date: 2014-12-10 17:19 +0200 http://bitbucket.org/pypy/pypy/changeset/8471e5574836/ Log:small progress diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py --- a/pypy/module/micronumpy/boxes.py +++ b/pypy/module/micronumpy/boxes.py @@ -601,6 +601,10 @@ #arr.storage[i] = arg[i] return W_UnicodeBox(arr, 0, arr.dtype) +class W_ObjectBox(W_GenericBox): +def __init__(self, w_obj): +self.w_obj = w_obj + W_GenericBox.typedef = TypeDef("numpy.generic", __new__ = interp2app(W_GenericBox.descr__new__.im_func), diff --git a/pypy/module/micronumpy/descriptor.py b/pypy/module/micronumpy/descriptor.py --- a/pypy/module/micronumpy/descriptor.py +++ b/pypy/module/micronumpy/descriptor.py @@ -850,6 +850,13 @@ char=NPY.UINTPLTR, w_box_type=space.gettypefor(boxes.W_ULongBox), ) +self.w_objectdtype = W_Dtype( +types.ObjectType(), +num=NPY.OBJECT, +kind=NPY.OBJECTLTR, +char=NPY.OBJECTLTR, +w_box_type=space.gettypefor(boxes.W_ObjectBox), +) aliases = { NPY.BOOL:['bool_', 'bool8'], NPY.BYTE:['byte'], @@ -868,6 +875,7 @@ NPY.CLONGDOUBLE: ['clongdouble', 'clongfloat'], NPY.STRING: ['string_', 'str'], NPY.UNICODE: ['unicode_'], +NPY.OBJECT: ['object_'], } self.alternate_constructors = { NPY.BOOL: [space.w_bool], @@ -886,6 +894,8 @@ NPY.UNICODE: [space.w_unicode], NPY.VOID: [space.gettypefor(boxes.W_GenericBox)], #space.w_buffer, # XXX no buffer in space +NPY.OBJECT: [space.gettypefor(boxes.W_ObjectBox), + space.w_object], } float_dtypes = [self.w_float16dtype, self.w_float32dtype, self.w_float64dtype, self.w_floatlongdtype] @@ -905,7 +915,7 @@ self.w_int64dtype, self.w_uint64dtype, ] + float_dtypes + complex_dtypes + [ self.w_stringdtype, self.w_unicodedtype, self.w_voiddtype, -self.w_intpdtype, self.w_uintpdtype, +self.w_intpdtype, self.w_uintpdtype, self.w_objectdtype, ] self.float_dtypes_by_num_bytes = sorted( (dtype.elsize, dtype) @@ -957,6 +967,7 @@ 'USHORT': self.w_uint16dtype, 'FLOAT': self.w_float32dtype, 'BOOL': self.w_booldtype, +'OBJECT': self.w_objectdtype, } typeinfo_partial = { diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py --- a/pypy/module/micronumpy/types.py +++ b/pypy/module/micronumpy/types.py @@ -1614,6 +1614,20 @@ BoxType = boxes.W_ComplexLongBox ComponentBoxType = boxes.W_FloatLongBox +class ObjectType(BaseType): +T = lltype.Signed + +def get_element_size(self): +return rffi.sizeof(lltype.Signed) + +def coerce(self, space, dtype, w_item): +if isinstance(w_item, boxes.W_ObjectBox): +return w_item +return boxes.W_ObjectBox(w_item) + +def store(self, arr, i, offset, box): +self._write(arr.storage, i, offset, self.unbox(box)) + class FlexibleType(BaseType): def get_element_size(self): return rffi.sizeof(self.T) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy object-dtype: merge default
Author: Maciej Fijalkowski Branch: object-dtype Changeset: r74880:207037db3449 Date: 2014-12-10 17:19 +0200 http://bitbucket.org/pypy/pypy/changeset/207037db3449/ Log:merge default diff too long, truncating to 2000 out of 58563 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -89,6 +89,7 @@ ^pypy/doc/image/lattice3\.png$ ^pypy/doc/image/stackless_informal\.png$ ^pypy/doc/image/parsing_example.+\.png$ +^rpython/doc/_build/.*$ ^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$ ^compiled ^.git/ diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -23,6 +23,7 @@ the pypy-dev team + Building @@ -36,4 +37,4 @@ to use virtualenv with the resulting pypy-c as the interpreter; you can find more details about various installation schemes here: -http://doc.pypy.org/en/latest/getting-started.html#installing-pypy +http://doc.pypy.org/en/latest/install.html diff --git a/ctypes_configure/doc/configure.txt b/ctypes_configure/doc/configure.txt --- a/ctypes_configure/doc/configure.txt +++ b/ctypes_configure/doc/configure.txt @@ -19,6 +19,4 @@ usage = -`sample.py`_ explains in details how to use it. - -.. _`sample.py`: http://codespeak.net/svn/pypy/dist/ctypes_configure/doc/sample.py +:source:`sample.py ` explains in details how to use it. diff --git a/lib-python/2.7/subprocess.py b/lib-python/2.7/subprocess.py --- a/lib-python/2.7/subprocess.py +++ b/lib-python/2.7/subprocess.py @@ -655,6 +655,21 @@ """Create new Popen instance.""" _cleanup() +# --- PyPy hack, see _pypy_install_libs_after_virtualenv() --- +# match arguments passed by different versions of virtualenv +if args[1:] in ( +['-c', 'import sys; print(sys.prefix)'],# 1.6 10ba3f3c +['-c', "\nimport sys\nprefix = sys.prefix\n"# 1.7 0e9342ce + "if sys.version_info[0] == 3:\n" + "prefix = prefix.encode('utf8')\n" + "if hasattr(sys.stdout, 'detach'):\n" + "sys.stdout = sys.stdout.detach()\n" + "elif hasattr(sys.stdout, 'buffer'):\n" + "sys.stdout = sys.stdout.buffer\nsys.stdout.write(prefix)\n"], +['-c', 'import sys;out=sys.stdout;getattr(out, "buffer"' + ', out).write(sys.prefix.encode("utf-8"))']): # 1.7.2 a9454bce +_pypy_install_libs_after_virtualenv(args[0]) + if not isinstance(bufsize, (int, long)): raise TypeError("bufsize must be an integer") @@ -1560,6 +1575,27 @@ self.send_signal(signal.SIGKILL) +def _pypy_install_libs_after_virtualenv(target_executable): +# https://bitbucket.org/pypy/pypy/issue/1922/future-proofing-virtualenv +# +# PyPy 2.4.1 turned --shared on by default. This means the pypy binary +# depends on the 'libpypy-c.so' shared library to be able to run. +# The virtualenv code existing at the time did not account for this +# and would break. Try to detect that we're running under such a +# virtualenv in the "Testing executable with" phase and copy the +# library ourselves. +caller = sys._getframe(2) +if ('virtualenv_version' in caller.f_globals and + 'copyfile' in caller.f_globals): +dest_dir = sys.pypy_resolvedirof(target_executable) +src_dir = sys.pypy_resolvedirof(sys.executable) +for libname in ['libpypy-c.so']: +dest_library = os.path.join(dest_dir, libname) +src_library = os.path.join(src_dir, libname) +if os.path.exists(src_library): +caller.f_globals['copyfile'](src_library, dest_library) + + def _demo_posix(): # # Example 1: Simple redirection: Get process list diff --git a/lib-python/conftest.py b/lib-python/conftest.py --- a/lib-python/conftest.py +++ b/lib-python/conftest.py @@ -59,7 +59,7 @@ def __init__(self, basename, core=False, compiler=None, usemodules='', skip=None): self.basename = basename -self._usemodules = usemodules.split() + ['signal', 'rctime', 'itertools', '_socket'] +self._usemodules = usemodules.split() + ['signal', 'time', 'itertools', '_socket'] self._compiler = compiler self.core = core self.skip = skip diff --git a/lib_pypy/grp.py b/lib_pypy/grp.py --- a/lib_pypy/grp.py +++ b/lib_pypy/grp.py @@ -66,11 +66,12 @@ @builtinify def getgrnam(name): -if not isinstance(name, str): +if not isinstance(name, basestring): raise TypeError("expected string") +name = str(name) res = libc.getgrnam(name) if not res: -raise KeyError(name) +raise KeyError("'getgrnam(): name not found: %s'" % name) return _group_from_gstruct(res) @builtinify diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -29,7 +29,7 @@ # --allworkingmodules wor
[pypy-commit] pypy default: formatting
Author: Maciej Fijalkowski Branch: Changeset: r74881:6cc9bad3f7f5 Date: 2014-12-10 17:46 +0200 http://bitbucket.org/pypy/pypy/changeset/6cc9bad3f7f5/ Log:formatting diff --git a/rpython/jit/metainterp/optimizeopt/pure.py b/rpython/jit/metainterp/optimizeopt/pure.py --- a/rpython/jit/metainterp/optimizeopt/pure.py +++ b/rpython/jit/metainterp/optimizeopt/pure.py @@ -42,8 +42,9 @@ oldop = self.pure_operations.get(args, None) if oldop is not None and oldop.getdescr() is op.getdescr(): assert oldop.getopnum() == op.getopnum() -self.optimizer.make_equal_to(op.result, self.getvalue(oldop.result), - True) +self.optimizer.make_equal_to(op.result, + self.getvalue(oldop.result), + True) return else: self.pure_operations[args] = op ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof: pypy_execute_frame_trampoline can (obviosuly) execute random python code, so we need to teach llexternal about it. Without, you get e.g. the wrong asmgcc labels, etc.
Author: Antonio Cuni Branch: vmprof Changeset: r74883:59ba61e4f315 Date: 2014-12-10 16:37 + http://bitbucket.org/pypy/pypy/changeset/59ba61e4f315/ Log:pypy_execute_frame_trampoline can (obviosuly) execute random python code, so we need to teach llexternal about it. Without, you get e.g. the wrong asmgcc labels, etc. diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -56,7 +56,8 @@ [llmemory.GCREF, llmemory.GCREF, llmemory.GCREF], llmemory.GCREF, compilation_info=eci, -_nowrapper=True, sandboxsafe=True) +_nowrapper=True, sandboxsafe=True, +random_effects_on_gcobjs=True) pypy_vmprof_init = rffi.llexternal("pypy_vmprof_init", [], lltype.Void, compilation_info=eci) vmprof_enable = rffi.llexternal("vmprof_enable", [rffi.CCHARP, rffi.LONG], lltype.Void, compilation_info=eci) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (cfbolz, tanzim, arigo)
Author: Armin Rigo Branch: Changeset: r74884:a3b346cf3412 Date: 2014-12-10 16:43 + http://bitbucket.org/pypy/pypy/changeset/a3b346cf3412/ Log:(cfbolz, tanzim, arigo) meh. diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -125,6 +125,8 @@ else: return self.space.builtin +_NO_CELLS = [] + @jit.unroll_safe def initialize_frame_scopes(self, outer_func, code): # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS. @@ -143,7 +145,7 @@ nfreevars = len(code.co_freevars) if not nfreevars: if not ncellvars: -self.cells = [] +self.cells = self._NO_CELLS return# no self.cells needed - fast path elif outer_func is None: space = self.space ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (cfbolz, arigo)
Author: Armin Rigo Branch: Changeset: r74885:479bfad309e3 Date: 2014-12-10 17:59 + http://bitbucket.org/pypy/pypy/changeset/479bfad309e3/ Log:(cfbolz, arigo) no cookie diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -373,7 +373,7 @@ tup_w = w_self._pure_lookup_where_with_method_cache(name, version_tag) w_class, w_value = tup_w if needs_to_unwrap_cell(space, w_value): -return w_class, w_value.value +return w_class, w_value.w_value return tup_w # don't make a new tuple, reuse the old one def _pure_lookup_where_possibly_with_method_cache(w_self, name, version_tag): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: Krakatau takes a long time to warmup, so discard warmup iterations.
Author: Laurence Tratt Branch: Changeset: r294:63916bb5a798 Date: 2014-12-10 17:48 + http://bitbucket.org/pypy/benchmarks/changeset/63916bb5a798/ Log:Krakatau takes a long time to warmup, so discard warmup iterations. When it is warmed up, it runs much faster than cold, so we then need to run things several times to make it long enough to be reliable. diff --git a/own/bm_krakatau.py b/own/bm_krakatau.py --- a/own/bm_krakatau.py +++ b/own/bm_krakatau.py @@ -47,19 +47,22 @@ source = javaclass.generateAST(c, makeGraph).print_() +WARMUP_ITERATIONS = 30 # Krakatau needs a number of iterations to warmup... + def main(n): l = [] old_stdout = sys.stdout sys.stdout = cStringIO.StringIO() try: -for i in range(n): +for i in range(WARMUP_ITERATIONS + n): t0 = time.time() -decompileClass() +for j in range(4): +decompileClass() time_elapsed = time.time() - t0 l.append(time_elapsed) finally: sys.stdout = old_stdout -return l +return l[WARMUP_ITERATIONS:] if __name__ == "__main__": parser = optparse.OptionParser( ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Makes no sense to have f_lineno end up by complete chance as a 32-bit int...
Author: Armin Rigo Branch: Changeset: r74886:bc40f87eddfc Date: 2014-12-10 18:17 + http://bitbucket.org/pypy/pypy/changeset/bc40f87eddfc/ Log:Makes no sense to have f_lineno end up by complete chance as a 32-bit int... diff --git a/pypy/module/cpyext/frameobject.py b/pypy/module/cpyext/frameobject.py --- a/pypy/module/cpyext/frameobject.py +++ b/pypy/module/cpyext/frameobject.py @@ -58,7 +58,7 @@ w_globals = from_ref(space, py_frame.c_f_globals) frame = space.FrameClass(space, code, w_globals, outer_func=None) -frame.f_lineno = py_frame.c_f_lineno +frame.f_lineno = rffi.getintfield(py_frame, 'c_f_lineno') w_obj = space.wrap(frame) track_reference(space, py_obj, w_obj) return w_obj ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit