[pypy-commit] pypy default: add multiarray.empty_like()
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68463:a0190dd8fc77 Date: 2013-12-18 03:52 -0500 http://bitbucket.org/pypy/pypy/changeset/a0190dd8fc77/ Log:add multiarray.empty_like() 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 @@ -11,6 +11,7 @@ 'zeros': 'interp_numarray.zeros', 'empty': 'interp_numarray.zeros', 'ones': 'interp_numarray.ones', +'empty_like': 'interp_numarray.empty_like', '_reconstruct' : 'interp_numarray._reconstruct', 'scalar' : 'interp_numarray.build_scalar', 'dot': 'interp_arrayops.dot', 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 @@ -1465,6 +1465,16 @@ w_arr.fill(space, one) return space.wrap(w_arr) +@unwrap_spec(subok=bool) +def empty_like(space, w_a, w_dtype=None, w_order=None, subok=True): +w_a = convert_to_array(space, w_a) +if subok and type(w_a) is not W_NDimArray: +raise OperationError(space.w_NotImplementedError, space.wrap( +subtypes not implemented)) +if w_dtype is None: +w_dtype = w_a.get_dtype() +return zeros(space, w_a.descr_get_shape(space), w_dtype) + def _reconstruct(space, w_subtype, w_shape, w_dtype): return descr_new_array(space, w_subtype, w_shape, w_dtype) 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 @@ -345,7 +345,7 @@ # TypeError raises((TypeError, AttributeError), 'x.ndim = 3') -def test_init(self): +def test_zeros(self): from numpypy import zeros a = zeros(15) # Check that storage was actually zero'd. @@ -355,6 +355,33 @@ assert a[13] == 5.3 assert zeros(()).shape == () +def test_empty_like(self): +import numpy as np +a = np.zeros((2, 3)) +assert a.shape == (2, 3) +a[0,0] = 1 +b = np.empty_like(a) +assert b.shape == a.shape +assert b.dtype == a.dtype +assert b[0,0] != 1 +b = np.empty_like(a, dtype='i4') +assert b.shape == a.shape +assert b.dtype == np.dtype('i4') +assert b[0,0] != 1 +b = np.empty_like([1,2,3]) +assert b.shape == (3,) +assert b.dtype == np.int_ + +class A(np.ndarray): +pass +import sys +if '__pypy__' not in sys.builtin_module_names: +b = np.empty_like(A((2, 3))) +assert b.shape == (2, 3) +assert type(b) is A +else: +raises(NotImplementedError, np.empty_like, A((2, 3))) + def test_size(self): from numpypy import array,arange,cos assert array(3).size == 1 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: add a single run benchmark
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r903:de7d92d8fc1d Date: 2013-12-18 11:47 +0200 http://bitbucket.org/pypy/buildbot/changeset/de7d92d8fc1d/ Log:add a single run benchmark diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -615,6 +615,50 @@ if trigger: # if provided trigger schedulers that depend on this one self.addStep(Trigger(schedulerNames=[trigger])) +class JITBenchmarkSingleRun(factory.BuildFactory): +def __init__(self, platform='linux', host='tannit', postfix=''): +factory.BuildFactory.__init__(self) + +repourl = 'https://bitbucket.org/pypy/benchmarks' +update_hg(platform, self, repourl, 'benchmarks', use_branch=True, + force_branch='single-run') +# +setup_steps(platform, self) +if host == 'tannit': +lock = TannitCPU +elif host == 'speed_python': +lock = SpeedPythonCPU +else: +assert False, 'unknown host %s' % host + +self.addStep( +Translate( +translationArgs=['-Ojit'], +targetArgs=[], +haltOnFailure=True, +# this step can be executed in parallel with other builds +locks=[lock.access('counting')], +) +) +pypy_c_rel = ../build/pypy/goal/pypy-c +self.addStep(ShellCmd( +# this step needs exclusive access to the CPU +locks=[lock.access('exclusive')], +description=run benchmarks on top of pypy-c, +command=[python, runner.py, '--output-filename', 'result.json', + '--python', pypy_c_rel, + '--full-store', + '--revision', WithProperties('%(got_revision)s'), + '--branch', WithProperties('%(branch)s'), + ], +workdir='./benchmarks', +timeout=3600)) +# a bit obscure hack to get both os.path.expand and a property +filename = '%(got_revision)s' + (postfix or '') +resfile = os.path.expanduser(~/bench_results_new/%s.json % filename) +self.addStep(transfer.FileUpload(slavesrc=benchmarks/result.json, + masterdest=WithProperties(resfile), + workdir=.)) class JITBenchmark(factory.BuildFactory): def __init__(self, platform='linux', host='tannit', postfix=''): diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py --- a/bot2/pypybuildbot/master.py +++ b/bot2/pypybuildbot/master.py @@ -147,6 +147,9 @@ pypyJITBenchmarkFactory_tannit = pypybuilds.JITBenchmark() pypyJITBenchmarkFactory64_tannit = pypybuilds.JITBenchmark(platform='linux64', postfix='-64') +pypyJITBenchmarkFactory64_speed = pypybuilds.JITBenchmarkSingleRun( +platform='linux64', +postfix='-64') pypyNumpyCompatability = pypybuilds.NativeNumpyTests(platform='linux64') @@ -180,7 +183,7 @@ JITONLYLINUXPPC64 = jitonly-own-linux-ppc-64 JITBENCH = jit-benchmark-linux-x86-32 JITBENCH64 = jit-benchmark-linux-x86-64 -JITBENCH64_2 = 'jit-benchmark-linux-x86-64-2' +JITBENCH64_NEW = 'jit-benchmark-linux-x86-64-single-run' CPYTHON_64 = cpython-2-benchmark-x86-64 NUMPY_64 = numpy-compatability-linux-x86-64 # buildbot builder @@ -354,6 +357,12 @@ category: benchmark-run, # the locks are acquired with fine grain inside the build }, + {name: JITBENCH64_NEW, +slavenames: [speed-python-64], +builddir: JITBENCH64_NEW, +factory: pypyJITBenchmarkFactory64_speed, +category: benchmark-run, +}, {name: MACOSX32, slavenames: [minime], builddir: MACOSX32, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: these days we have to specify if you can force it
Author: Maciej Fijalkowski fij...@gmail.com Branch: Changeset: r904:e4dcdf51ee43 Date: 2013-12-18 11:50 +0200 http://bitbucket.org/pypy/buildbot/changeset/e4dcdf51ee43/ Log:these days we have to specify if you can force it diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py --- a/bot2/pypybuildbot/master.py +++ b/bot2/pypybuildbot/master.py @@ -273,6 +273,7 @@ JITONLYLINUXPPC64, JITBENCH, JITBENCH64, +JITBENCH64_NEW, NUMPY_64, ] + ARM.builderNames, properties=[]), ] + ARM.schedulers, ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: empty_like support subtypes
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68464:5a4adfaff6c6 Date: 2013-12-18 04:30 -0500 http://bitbucket.org/pypy/pypy/changeset/5a4adfaff6c6/ Log:empty_like support subtypes 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 @@ -1468,12 +1468,13 @@ @unwrap_spec(subok=bool) def empty_like(space, w_a, w_dtype=None, w_order=None, subok=True): w_a = convert_to_array(space, w_a) -if subok and type(w_a) is not W_NDimArray: -raise OperationError(space.w_NotImplementedError, space.wrap( -subtypes not implemented)) if w_dtype is None: -w_dtype = w_a.get_dtype() -return zeros(space, w_a.descr_get_shape(space), w_dtype) +dtype = w_a.get_dtype() +else: +dtype = space.interp_w(interp_dtype.W_Dtype, +space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) +return W_NDimArray.from_shape(space, w_a.get_shape(), dtype=dtype, + w_instance=w_a if subok else None) def _reconstruct(space, w_subtype, w_shape, w_dtype): return descr_new_array(space, w_subtype, w_shape, w_dtype) 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 @@ -357,6 +357,9 @@ def test_empty_like(self): import numpy as np +a = np.empty_like(np.zeros(())) +assert a.shape == () +assert a.dtype == np.float_ a = np.zeros((2, 3)) assert a.shape == (2, 3) a[0,0] = 1 @@ -371,16 +374,14 @@ b = np.empty_like([1,2,3]) assert b.shape == (3,) assert b.dtype == np.int_ - class A(np.ndarray): pass -import sys -if '__pypy__' not in sys.builtin_module_names: -b = np.empty_like(A((2, 3))) -assert b.shape == (2, 3) -assert type(b) is A -else: -raises(NotImplementedError, np.empty_like, A((2, 3))) +b = np.empty_like(A((2, 3))) +assert b.shape == (2, 3) +assert type(b) is A +b = np.empty_like(A((2, 3)), subok=False) +assert b.shape == (2, 3) +assert type(b) is np.ndarray def test_size(self): from numpypy import array,arange,cos ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix subtypes of numpy scalars
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68466:819adf960b3e Date: 2013-12-18 04:51 -0500 http://bitbucket.org/pypy/pypy/changeset/819adf960b3e/ Log:fix subtypes of numpy scalars 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 @@ -1146,8 +1146,6 @@ w_base=w_buffer, writable=buf.is_writable()) -if not shape: -return W_NDimArray.new_scalar(space, dtype) order = order_converter(space, w_order, NPY_CORDER) if order == NPY_CORDER: order = 'C' diff --git a/pypy/module/micronumpy/test/test_subtype.py b/pypy/module/micronumpy/test/test_subtype.py --- a/pypy/module/micronumpy/test/test_subtype.py +++ b/pypy/module/micronumpy/test/test_subtype.py @@ -33,6 +33,11 @@ self = ndarray.__new__(subtype, shape, dtype) self.id = 'subtype' return self +a = C((), int) +assert type(a) is C +assert a.shape == () +assert a.dtype is dtype(int) +assert a.id == 'subtype' a = C([2, 2], int) assert isinstance(a, C) assert isinstance(a, ndarray) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: cleanup
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68465:b63fad133ab6 Date: 2013-12-18 04:53 -0500 http://bitbucket.org/pypy/pypy/changeset/b63fad133ab6/ Log:cleanup 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 @@ -539,7 +539,7 @@ def descr_astype(self, space, w_dtype): dtype = space.interp_w(interp_dtype.W_Dtype, - space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) +space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) impl = self.implementation if isinstance(impl, scalar.Scalar): return W_NDimArray.new_scalar(space, dtype, impl.value) @@ -1445,25 +1445,18 @@ @unwrap_spec(order=str) def zeros(space, w_shape, w_dtype=None, order='C'): dtype = space.interp_w(interp_dtype.W_Dtype, -space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype) -) +space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) shape = _find_shape(space, w_shape, dtype) -if not shape: -return W_NDimArray.new_scalar(space, dtype, space.wrap(0)) -return space.wrap(W_NDimArray.from_shape(space, shape, dtype=dtype, order=order)) +return W_NDimArray.from_shape(space, shape, dtype=dtype, order=order) @unwrap_spec(order=str) def ones(space, w_shape, w_dtype=None, order='C'): dtype = space.interp_w(interp_dtype.W_Dtype, -space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype) -) +space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) shape = _find_shape(space, w_shape, dtype) -if not shape: -return W_NDimArray.new_scalar(space, dtype, space.wrap(0)) w_arr = W_NDimArray.from_shape(space, shape, dtype=dtype, order=order) -one = dtype.box(1) -w_arr.fill(space, one) -return space.wrap(w_arr) +w_arr.fill(space, dtype.box(1)) +return w_arr @unwrap_spec(subok=bool) def empty_like(space, w_a, w_dtype=None, w_order=None, subok=True): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: ones lives at python-level in numpy now
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68467:12d7e32de888 Date: 2013-12-18 05:06 -0500 http://bitbucket.org/pypy/pypy/changeset/12d7e32de888/ Log:ones lives at python-level in numpy now 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 @@ -10,7 +10,6 @@ 'array': 'interp_numarray.array', 'zeros': 'interp_numarray.zeros', 'empty': 'interp_numarray.zeros', -'ones': 'interp_numarray.ones', 'empty_like': 'interp_numarray.empty_like', '_reconstruct' : 'interp_numarray._reconstruct', 'scalar' : 'interp_numarray.build_scalar', 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 @@ -1447,15 +1447,6 @@ shape = _find_shape(space, w_shape, dtype) return W_NDimArray.from_shape(space, shape, dtype=dtype, order=order) -@unwrap_spec(order=str) -def ones(space, w_shape, w_dtype=None, order='C'): -dtype = space.interp_w(interp_dtype.W_Dtype, -space.call_function(space.gettypefor(interp_dtype.W_Dtype), w_dtype)) -shape = _find_shape(space, w_shape, dtype) -w_arr = W_NDimArray.from_shape(space, shape, dtype=dtype, order=order) -w_arr.fill(space, dtype.box(1)) -return w_arr - @unwrap_spec(subok=bool) def empty_like(space, w_a, w_dtype=None, w_order=None, subok=True): w_a = convert_to_array(space, w_a) diff --git a/pypy/module/micronumpy/test/dummy_module.py b/pypy/module/micronumpy/test/dummy_module.py --- a/pypy/module/micronumpy/test/dummy_module.py +++ b/pypy/module/micronumpy/test/dummy_module.py @@ -32,3 +32,8 @@ True_ = bool_(True) False_ = bool_(False) + +def ones(*args, **kwargs): +a = zeros(*args, **kwargs) +a.fill(1) +return a ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: these live at python-level in numpy also
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68468:e66481e62e53 Date: 2013-12-18 05:15 -0500 http://bitbucket.org/pypy/pypy/changeset/e66481e62e53/ Log:these live at python-level in numpy also 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 @@ -106,8 +106,6 @@ ('logaddexp2', 'logaddexp2'), ('real', 'real'), ('imag', 'imag'), -('ones_like', 'ones_like'), -('zeros_like', 'zeros_like'), ]: interpleveldefs[exposed] = interp_ufuncs.get(space).%s % impl diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -690,9 +690,6 @@ allow_complex: False}), (logaddexp2, logaddexp2, 2, {promote_to_float: True, allow_complex: False}), - -(ones_like, ones_like, 1), -(zeros_like, zeros_like, 1), ]: self.add_ufunc(space, *ufunc_def) 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 @@ -1029,22 +1029,6 @@ assert logaddexp2(float('inf'), float('-inf')) == float('inf') assert logaddexp2(float('inf'), float('inf')) == float('inf') -def test_ones_like(self): -from numpypy import array, ones_like - -assert ones_like(False) == array(True) -assert ones_like(2) == array(1) -assert ones_like(2.) == array(1.) -assert ones_like(complex(2)) == array(complex(1)) - -def test_zeros_like(self): -from numpypy import array, zeros_like - -assert zeros_like(True) == array(False) -assert zeros_like(2) == array(0) -assert zeros_like(2.) == array(0.) -assert zeros_like(complex(2)) == array(complex(0)) - def test_accumulate(self): from numpypy import add, multiply, arange assert (add.accumulate([2, 3, 5]) == [2, 5, 10]).all() 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 @@ -300,14 +300,6 @@ def min(self, v1, v2): return min(v1, v2) -@simple_unary_op -def ones_like(self, v): -return 1 - -@simple_unary_op -def zeros_like(self, v): -return 0 - @raw_unary_op def rint(self, v): float64 = Float64() @@ -1543,14 +1535,6 @@ except ValueError: return rfloat.NAN, rfloat.NAN -@complex_unary_op -def ones_like(self, v): -return 1, 0 - -@complex_unary_op -def zeros_like(self, v): -return 0, 0 - class Complex64(ComplexFloating, BaseType): T = rffi.FLOAT BoxType = interp_boxes.W_Complex64Box ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk default: update test
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r541:2c7d7bfa6077 Date: 2013-12-18 17:05 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/2c7d7bfa6077/ Log:update test diff --git a/spyvm/test/jittest/test_basic.py b/spyvm/test/jittest/test_basic.py --- a/spyvm/test/jittest/test_basic.py +++ b/spyvm/test/jittest/test_basic.py @@ -23,39 +23,29 @@ jump(p0, p3, i61, p12, p14, p16, p18, p20, p22, p24, p26, p28, p30, p32, p34, p36, p38, i64, descr=TargetToken(169145008)) ) self.assert_matches(traces[0].bridges[0], -i18 = getfield_gc(ConstPtr(ptr17), descr=FieldS spyvm.interpreter.Interpreter.inst_interrupt_counter_size 20), -f20 = call(ConstClass(ll_time.ll_time_time), descr=Callf 8 EF=4), -setfield_gc(ConstPtr(ptr17), i18, descr=FieldS spyvm.interpreter.Interpreter.inst_interrupt_check_counter 16), -guard_no_exception(descr=Guard0x9d3ee5c), -f22 = float_mul(f20, 1000.00), -call(ConstClass(set_errno), 0, descr=Callv 0 i EF=2), -f27 = call(ConstClass(fmod), f22, 536870911.00, descr=Callf 8 ff EF=2), -i29 = call(ConstClass(get_errno), descr=Calli 4 EF=2), -i30 = float_ne(f27, f27), -guard_false(i30, descr=Guard0x9d6ce20), -i31 = int_is_true(i29), -guard_false(i31, descr=Guard0x9d6cde4), -i32 = cast_float_to_int(f27), -i33 = getfield_gc(ConstPtr(ptr17), descr=FieldS spyvm.interpreter.Interpreter.inst_next_wakeup_tick 28), -i34 = int_is_zero(i33), -guard_true(i34, descr=Guard0x9d6cda8), -i35 = same_as(i18), -label(p0, p1, i16, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, i35, descr=TargetToken(164815776)), -guard_class(p0, ConstClass(MethodContextShadow), descr=Guard0x9d6cd6c), -p37 = getfield_gc(p0, descr=FieldP spyvm.shadow.MethodContextShadow.inst__w_method 44), -guard_value(p37, ConstPtr(ptr38), descr=Guard0x9d6cd30), -guard_not_invalidated(descr=Guard0x9d6ccf4), -i40 = int_le(i16, 10), -guard_true(i40, descr=Guard0x9d6ccb8), -i42 = int_add(i16, 1), -i44 = int_sub(i42, -1073741824), -i46 = uint_lt(i44, -2147483648), -guard_true(i46, descr=Guard0x9d6cc7c), -i48 = int_sub(i35, 1), -setfield_gc(ConstPtr(ptr17), i48, descr=FieldS spyvm.interpreter.Interpreter.inst_interrupt_check_counter 16), -i50 = int_le(i48, 0), -guard_false(i50, descr=Guard0x9d6cc40), -jump(p0, p1, i42, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, i48, descr=TargetToken(164815536)) +f18 = call(ConstClass(ll_time.ll_time_time), descr=Callf 8 EF=4) +setfield_gc(ConstPtr(ptr19), 1, descr=FieldS spyvm.interpreter.Interpreter.inst_interrupt_check_counter 24) +guard_no_exception(descr=Guard0x9732d30) +f22 = float_sub(f18, 1387380038.806162) +f24 = float_mul(f22, 1000.00) +i25 = cast_float_to_int(f24) +i27 = int_and(i25, 2147483647) +i28 = getfield_gc(ConstPtr(ptr19), descr=FieldS spyvm.interpreter.Interpreter.inst_next_wakeup_tick 36) +i29 = int_is_zero(i28) +guard_true(i29, descr=Guard0x9761ad8) +label(p0, p1, i16, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, descr=TargetToken(158475216)) +guard_class(p0, ConstClass(MethodContextShadow), descr=Guard0x9761a9c) +p31 = getfield_gc(p0, descr=FieldP spyvm.shadow.MethodContextShadow.inst__w_method 44) +guard_value(p31, ConstPtr(ptr32), descr=Guard0x9761a60) +guard_not_invalidated(descr=Guard0x9761a24) +i34 = int_le(i16, 10) +guard_true(i34, descr=Guard0x97619e8) +i36 = int_add(i16, 1) +i38 = int_sub(i36, -1073741824) +i40 = uint_lt(i38, -2147483648) +guard_true(i40, descr=Guard0x97619ac) +setfield_gc(ConstPtr(ptr19), , descr=FieldS spyvm.interpreter.Interpreter.inst_interrupt_check_counter 24) +jump(p0, p1, i36, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, , descr=TargetToken(158474976)) ) def test_constant_string(self, spy, tmpdir): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk default: ignore a few more files
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r537:46675f9fdb93 Date: 2013-12-18 13:58 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/46675f9fdb93/ Log:ignore a few more files diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -1,8 +1,12 @@ syntax: glob *.py[co] *~ -pypy-c-jit-62116-b027d4428675-linux +pypy-c-jit-* images/Squeak* +images/resources* +*package-cache/ +Squeak* +*TAGS targetimageloadingsmalltalk-*c images/package-cache versions ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk default: add cmdline arg to pass code to run as benchmark
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r534:16ef5cb0ae0c Date: 2013-12-18 13:21 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/16ef5cb0ae0c/ Log:add cmdline arg to pass code to run as benchmark diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py --- a/targetimageloadingsmalltalk.py +++ b/targetimageloadingsmalltalk.py @@ -61,6 +61,25 @@ except error.Exit, e: print e.msg +def _run_code(interp, code): +import time +selector = codeTest%d % int(time.time()) +try: +w_result = interp.perform( +interp.space.w_SmallInteger, +compile:classified:notifying:, +space.wrap_string(%s\r\n%s % (selector, code)), +space.wrap_string(spy-run-code), +space.w_nil +) +except interpreter.ReturnFromTopLevel, e: +print e.object +return 1 +except error.Exit, e: +print e.msg +return 1 +return _run_benchmark(interp, 0, selector, ) + space = objspace.ObjSpace() @@ -86,6 +105,7 @@ -n|--number [smallint, default: 0] -m|--method [benchmark on smallint] -a|--arg [string argument to #method] + -r|--run [shell escaped code string] [image path, default: Squeak.image] % argv[0] @@ -102,6 +122,7 @@ benchmark = None trace = False stringarg = +code = None while idx len(argv): arg = argv[idx] @@ -127,6 +148,10 @@ _arg_missing(argv, idx, arg) stringarg = argv[idx + 1] idx += 1 +elif arg in [-r, --run]: +_arg_missing(argv, idx, arg) +code = argv[idx + 1] +idx += 1 elif path is None: path = argv[idx] else: @@ -154,6 +179,8 @@ space.runtime_setup(argv[0]) if benchmark is not None: return _run_benchmark(interp, number, benchmark, stringarg) +elif code is not None: +return _run_code(interp, code) else: _run_image(interp) return 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c5: Make more public the attempt started at
Author: Armin Rigo ar...@tunes.org Branch: c5 Changeset: r556:808b5bebaf57 Date: 2013-12-18 17:05 +0100 http://bitbucket.org/pypy/stmgc/changeset/808b5bebaf57/ Log:Make more public the attempt started at https://bitbucket.org/arigo/arigo/raw/default/hack/stm/c5 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk default: add jittests like topaz does them
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r539:a37f452bc27c Date: 2013-12-18 15:18 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/a37f452bc27c/ Log:add jittests like topaz does them diff --git a/spyvm/test/jittest/__init__.py b/spyvm/test/jittest/__init__.py new file mode 100644 diff --git a/spyvm/test/jittest/base.py b/spyvm/test/jittest/base.py new file mode 100644 --- /dev/null +++ b/spyvm/test/jittest/base.py @@ -0,0 +1,121 @@ +import subprocess +import os + +# TODO: +from pypy.tool.jitlogparser.parser import SimpleParser, Op +from pypy.tool.jitlogparser.storage import LoopStorage + +from rpython.jit.metainterp.resoperation import opname +from rpython.jit.tool import oparser +from rpython.tool import logparser + + +BasePath = os.path.abspath( +os.path.join( +os.path.join(os.path.dirname(__file__), os.path.pardir), +os.path.pardir, +os.path.pardir +) +) +BenchmarkImage = os.path.join(os.path.dirname(__file__), benchmark.image) + +class BaseJITTest(object): +def run(self, spy, tmpdir, code): +proc = subprocess.Popen( +[str(spy), -r, code.replace(\n, \r\n), BenchmarkImage], +cwd=str(tmpdir), +env={PYPYLOG: jit-log-opt:%s % tmpdir.join(x.pypylog)} +) +proc.wait() +data = logparser.parse_log_file(str(tmpdir.join(x.pypylog)), verbose=False) +data = logparser.extract_category(data, jit-log-opt-) + +storage = LoopStorage() +traces = [SimpleParser.parse_from_input(t) for t in data] +main_loops = storage.reconnect_loops(traces) +traces_w = [] +for trace in traces: +if trace in main_loops: +traces_w.append(Trace(trace)) +else: +traces_w[len(traces_w) - 1].addbridge(trace) +return traces_w + +def assert_matches(self, trace, expected): +expected_lines = [ +line.strip() +for line in expected.splitlines() +if line and not line.isspace() +] +parser = Parser(None, None, {}, lltype, None, invent_fail_descr=None, nonstrict=True) +expected_ops = [parser.parse_next_op(l) for l in expected_lines] +aliases = {} +assert len(trace) == len(expected_ops) +for op, expected in zip(trace, expected_ops): +self._assert_ops_equal(aliases, op, expected) + +def _assert_ops_equal(self, aliases, op, expected): +assert op.name == expected.name +assert len(op.args) == len(expected.args) +for arg, expected_arg in zip(op.args, expected.args): +if arg in aliases: +arg = aliases[arg] +elif arg != expected_arg and expected_arg not in aliases.viewvalues(): +aliases[arg] = arg = expected_arg +assert arg == expected_arg + + +class Parser(oparser.OpParser): +def get_descr(self, poss_descr, allow_invent): +if poss_descr.startswith((TargetToken, Guard)): +return poss_descr +return super(Parser, self).get_descr(poss_descr, allow_invent) + +def getvar(self, arg): +return arg + +def create_op(self, opnum, args, res, descr): +return Op(opname[opnum].lower(), args, res, descr) + + +class Trace(object): +def __init__(self, trace): +self._trace = trace +self._bridges = [] +self._bridgeops = None +self._loop = None + +def addbridge(self, trace): +self._bridges.append(trace) + +@property +def bridges(self): +if self._bridgeops: +return self._bridgeops +else: +self._bridgeops = [] +for bridge in self._bridges: +self._bridgeops.append([op for op in bridge.operations if not op.name.startswith(debug_)]) +return self._bridgeops + +@property +def loop(self): +if self._loop: +return self._loop +else: +self._loop = self._parse_loop_from(self._trace) +return self._loop + +def _parse_loop_from(self, trace, label_seen=None): +_loop = [] +for idx, op in enumerate(self._trace.operations): +if label_seen and not op.name.startswith(debug_): +_loop.append(op) +if op.name == label: +if label_seen is None: # first label +label_seen = False +else: +label_seen = True # second label +if len(_loop) == 0: +raise ValueError(Loop body couldn't be found) +return _loop diff --git a/spyvm/test/jittest/benchmark.image b/spyvm/test/jittest/benchmark.image new file mode 100644 index ..848cffbe175dbf07a5d4bdc4f958ce92779dd171 GIT binary patch [cut] diff --git a/spyvm/test/jittest/conftest.py b/spyvm/test/jittest/conftest.py new file mode 100644 --- /dev/null +++
[pypy-commit] lang-smalltalk default: catch exception on os.fstat
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r536:552c99b5e77c Date: 2013-12-18 13:58 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/552c99b5e77c/ Log:catch exception on os.fstat diff --git a/spyvm/plugins/fileplugin.py b/spyvm/plugins/fileplugin.py --- a/spyvm/plugins/fileplugin.py +++ b/spyvm/plugins/fileplugin.py @@ -40,7 +40,10 @@ file_path = os.path.join(full_path, py_name) except OSError: raise PrimitiveFailedError -file_info = os.stat(file_path) +try: +file_info = os.stat(file_path) +except OSError: +raise PrimitiveFailedError w_name = space.wrap_string(py_name) w_creationTime = smalltalk_timestamp(space, file_info.st_ctime) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk default: allow just running literal code, as opposed to fair (using processes) benchmarking
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r538:5165739fe96b Date: 2013-12-18 13:59 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/5165739fe96b/ Log:allow just running literal code, as opposed to fair (using processes) benchmarking diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py --- a/targetimageloadingsmalltalk.py +++ b/targetimageloadingsmalltalk.py @@ -61,7 +61,7 @@ except error.Exit, e: print e.msg -def _run_code(interp, code): +def _run_code(interp, code, as_benchmark=False): import time selector = codeTest%d % int(time.time()) try: @@ -78,7 +78,24 @@ except error.Exit, e: print e.msg return 1 -return _run_benchmark(interp, 0, selector, ) + +if not as_benchmark: +try: +w_result = interp.perform(space.wrap_int(0), selector) +except interpreter.ReturnFromTopLevel, e: +print e.object +return 1 +except error.Exit, e: +print e.msg +return 1 +if w_result: +if isinstance(w_result, model.W_BytesObject): +print w_result.as_string().replace('\r', '\n') +else: +print w_result.as_repr_string().replace('\r', '\n') +return 0 +else: +return _run_benchmark(interp, 0, selector, ) space = objspace.ObjSpace() @@ -105,7 +122,8 @@ -n|--number [smallint, default: 0] -m|--method [benchmark on smallint] -a|--arg [string argument to #method] - -r|--run [shell escaped code string] + -r|--run [code string] + -b|--benchmark [code string] [image path, default: Squeak.image] % argv[0] @@ -123,6 +141,7 @@ trace = False stringarg = code = None +as_benchmark = False while idx len(argv): arg = argv[idx] @@ -151,6 +170,12 @@ elif arg in [-r, --run]: _arg_missing(argv, idx, arg) code = argv[idx + 1] +as_benchmark = False +idx += 1 +elif arg in [-b, --benchmark]: +_arg_missing(argv, idx, arg) +code = argv[idx + 1] +as_benchmark = True idx += 1 elif path is None: path = argv[idx] @@ -180,7 +205,7 @@ if benchmark is not None: return _run_benchmark(interp, number, benchmark, stringarg) elif code is not None: -return _run_code(interp, code) +return _run_code(interp, code, as_benchmark=as_benchmark) else: _run_image(interp) return 0 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk default: (hopefully) fix the millisecond clock issue for now
Author: Tim Felgentreff timfelgentr...@gmail.com Branch: Changeset: r540:182c667e14ff Date: 2013-12-18 16:10 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/182c667e14ff/ Log:(hopefully) fix the millisecond clock issue for now diff --git a/spyvm/constants.py b/spyvm/constants.py --- a/spyvm/constants.py +++ b/spyvm/constants.py @@ -146,6 +146,8 @@ TAGGED_MAXINT = 2 ** (LONG_BIT - 2) - 1 TAGGED_MININT = -2 ** (LONG_BIT - 2) +TAGGED_MASK = int(2 ** (LONG_BIT - 1) - 1) + # Entries into SO_SPECIAL_SELECTORS_ARRAY: #(#+ 1 #- 1 # 1 # 1 #= 1 #= 1 #= 1 #~= 1 #* 1 #/ 1 #\\ 1 #@ 1 #bitShift: 1 #// 1 #bitAnd: 1 #bitOr: 1 #at: 1 #at:put: 2 #size 0 #next 0 #nextPut: 1 #atEnd 0 #== 1 #class 0 #blockCopy: 1 #value 0 #value: 1 #do: 1 #new 0 #new: 1 #x 0 #y 0) diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py --- a/spyvm/interpreter.py +++ b/spyvm/interpreter.py @@ -5,7 +5,7 @@ from spyvm.tool.bitmanipulation import splitter from rpython.rlib import jit -from rpython.rlib import objectmodel, unroll, rarithmetic +from rpython.rlib import objectmodel, unroll class MissingBytecode(Exception): Bytecode not implemented yet. @@ -23,7 +23,9 @@ class Interpreter(object): - +_immutable_fields_ = [space, image, image_name, + max_stack_depth, interrupt_counter_size, + startup_time] _w_last_active_context = None cnt = 0 _last_indent = @@ -36,9 +38,11 @@ def __init__(self, space, image=None, image_name=, trace=False, max_stack_depth=constants.MAX_LOOP_DEPTH): +import time self.space = space self.image = image self.image_name = image_name +self.startup_time = time.time() self.max_stack_depth = max_stack_depth self.remaining_stack_depth = max_stack_depth self._loop = False @@ -176,16 +180,12 @@ def check_for_interrupts(self, s_frame): # parallel to Interpreter#checkForInterrupts -import time, math # Profiling is skipped # We don't adjust the check counter size # use the same time value as the primitive MILLISECOND_CLOCK -now = rarithmetic.intmask( -int(time.time()*1000) (constants.TAGGED_MAXINT/2 - 1) -) -# now = int(math.fmod(time.time()*1000, constants.TAGGED_MAXINT/2)) +now = self.time_now() # XXX the low space semaphore may be signaled here # Process inputs @@ -199,6 +199,11 @@ # We do not support external semaphores. # In cog, the method to add such a semaphore is only called in GC. +def time_now(self): +import time +from rpython.rlib.rarithmetic import intmask +return intmask(int((time.time() - self.startup_time) * 1000) constants.TAGGED_MASK) + def padding(self, symbol=' '): return symbol * (self.max_stack_depth - self.remaining_stack_depth) diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -1016,10 +1016,7 @@ @expose_primitive(MILLISECOND_CLOCK, unwrap_spec=[object]) def func(interp, s_frame, w_arg): -import time, math -return interp.space.wrap_int(rarithmetic.intmask( -int(time.time()*1000) (constants.TAGGED_MAXINT/2 - 1) -)) +return interp.space.wrap_int(interp.time_now()) @expose_primitive(SIGNAL_AT_MILLISECONDS, unwrap_spec=[object, object, int]) def func(interp, s_frame, w_delay, w_semaphore, timestamp): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c5: Initial import.
Author: Armin Rigo ar...@tunes.org Branch: c5 Changeset: r557:49446e74e137 Date: 2013-12-18 17:09 +0100 http://bitbucket.org/pypy/stmgc/changeset/49446e74e137/ Log:Initial import. diff --git a/c5/Makefile b/c5/Makefile new file mode 100644 --- /dev/null +++ b/c5/Makefile @@ -0,0 +1,10 @@ + +H_FILES = core.h pagecopy.h +C_FILES = core.c pagecopy.c + + +demo1: demo1.c $(C_FILES) $(H_FILES) + gcc -o $@ -O2 -g demo1.c $(C_FILES) -Wall + +clean: + rm -f demo1 diff --git a/c5/core.c b/c5/core.c new file mode 100644 --- /dev/null +++ b/c5/core.c @@ -0,0 +1,537 @@ +#define _GNU_SOURCE +#include stdlib.h +#include stdio.h +#include sys/mman.h +#include errno.h +#include assert.h +#include string.h + +#include core.h +#include pagecopy.h + + +/* This file only works on 64-bit Linux for now. The logic is based on + remapping pages around, which can get a bit confusing. Each thread + runs in its own process, so that it has its own mapping. The + processes share an mmap of length NB_PAGES, which is created shared + but anonymous, and passed to subprocesses by forking. + + The mmap's content does not depend on which process is looking at it: + it contains what we'll call mm pages, which is 4096 bytes of data + at some file offset (which all processes agree on). The term pgoff + used below means such an offset. It is a uint32_t expressed in units + of 4096 bytes; so the underlying mmap is limited to 2**32 pages or + 16TB. + + The mm pages are then mapped in each process at some address, and + their content is accessed with regular pointers. We'll call such a + page a local page. The term local is used because each process + has its own, different mapping. As it turns out, mm pages are + initially mapped sequentially as local pages, but this changes over + time. To do writes in a transaction, the data containing the object + is first duplicated --- so we allocate a fresh new mm page in the + mmap file, and copy the contents to it. Then we remap the new mm + page over the *same* local page as the original. So from this + process' point of view, the object is still at the same address, but + writes to it now happen to go to the new mm page instead of the old + one. + + The local pages are usually referenced by pointers, but may also be + expressed as an index, called the local index of the page. +*/ + +#ifdef STM_TESTS +# define NB_PAGES (256*10) // 10MB +#else +# define NB_PAGES (256*1024) // 1GB +#endif +#define MAP_PAGES_FLAGS (MAP_SHARED|MAP_ANONYMOUS) + +#define CACHE_LINE_SIZE 128// conservatively large value to avoid aliasing + +#define PGKIND_NEVER_USED 0 +#define LARGE_OBJECT_WORDS36/* range(2, LARGE_OBJECT_WORDS) */ +#define PGKIND_FREED 0xff +#define PGKIND_WRITE_HISTORY 0xfe +#define PGKIND_SHARED_DESCRIPTOR 0xfd /* only for the first mm page */ + +struct page_header_s { +/* Every page starts with one such structure */ +uint16_t version; /* when the data in the page was written */ +uint8_t modif_head; /* head of a chained list of objects in this + page that have modified == this-version */ +uint8_t kind; /* either PGKIND_xxx or a number in + range(2, LARGE_OBJECT_WORDS) */ +uint32_t pgoff; /* the mm page offset */ +}; + +struct read_marker_s { +/* We associate a single byte to every object, by simply dividing + the address of the object by 16. This is the last byte of the + last time we have read the object. See stm_read(). */ +unsigned char c; +}; + +struct write_history_s { +struct write_history_s *previous_older_transaction; +uint16_t transaction_version; +uint32_t nb_updates; +uint32_t updates[];/* pairs (local_index, new_pgoff) */ +}; + +struct shared_descriptor_s { +/* There is a single shared descriptor. This regroups all data + that needs to be dynamically shared among processes. The + first mm page is used for this. */ +union { +struct page_header_s header; +char _pad0[CACHE_LINE_SIZE]; +}; +union { +uint64_t index_page_never_used; +char _pad1[CACHE_LINE_SIZE]; +}; +union { +unsigned int next_transaction_version; +char _pad2[CACHE_LINE_SIZE]; +}; +union { +struct write_history_s *most_recent_committed_transaction; +char _pad3[CACHE_LINE_SIZE]; +}; +}; + +struct alloc_for_size_s { +char *next; +char *end; +}; + +struct local_data_s { +/* This is just a bunch of global variables, but during testing, + we save it all away and restore different ones to simulate + different forked processes. */ +char *read_markers; +struct read_marker_s *current_read_markers; +uint16_t transaction_version; +struct write_history_s *base_page_mapping; +struct write_history_s
[pypy-commit] stmgc c5: Use MADV_DONTNEED to clear the read marker pages after 255 transactions.
Author: Armin Rigo ar...@tunes.org Branch: c5 Changeset: r558:d3ce94726f63 Date: 2013-12-18 17:32 +0100 http://bitbucket.org/pypy/stmgc/changeset/d3ce94726f63/ Log:Use MADV_DONTNEED to clear the read marker pages after 255 transactions. diff --git a/c5/core.c b/c5/core.c --- a/c5/core.c +++ b/c5/core.c @@ -36,6 +36,12 @@ writes to it now happen to go to the new mm page instead of the old one. + This is basically what happens automatically with fork() for regular + memory; the difference is that at commit time, we try to publish the + modified pages back for everybody to see. This involves possibly + merging changes done by other processes to other objects from the + same page. + The local pages are usually referenced by pointers, but may also be expressed as an index, called the local index of the page. */ @@ -134,6 +140,11 @@ (unsigned char)(uintptr_t)stm_local.current_read_markers); } +static struct read_marker_s *get_current_read_marker(struct object_s *object) +{ +return stm_local.current_read_markers + (((uintptr_t)object) 4); +} + void _stm_write_slowpath(struct object_s *); void stm_write(struct object_s *object) @@ -282,6 +293,26 @@ stm_local.current_read_markers += num; } +static void clear_all_read_markers(void) +{ +/* set the largest possible read marker number, to find the last + possible read_marker to clear */ +stm_set_read_marker_number(0xff); + +uint64_t page_index = stm_shared_descriptor-index_page_never_used; +char *o = ((char *)stm_shared_descriptor) + page_index * 4096; +char *m = (char *)get_current_read_marker((struct object_s *)o); +size_t length = m - (char *)stm_local.read_markers; +length = (length + 4095) ~4095; + +int r = madvise(stm_local.read_markers, length, MADV_DONTNEED); +if (r != 0) { +perror(madvise() failure); +abort(); +} +stm_set_read_marker_number(1); +} + void stm_setup(void) { if (sizeof(char *) != 8) { @@ -491,8 +522,12 @@ } stm_local.writes_by_this_transaction = NULL; -assert(stm_get_read_marker_number() 0xff); -stm_local.current_read_markers++; +if (stm_get_read_marker_number() 0xff) { +stm_local.current_read_markers++; +} +else { +clear_all_read_markers(); +} return !conflict; } ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix promote_to_largest in reduce operations (fixes issue1663)
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68469:912fe4190438 Date: 2013-12-18 14:41 -0500 http://bitbucket.org/pypy/pypy/changeset/912fe4190438/ Log:fix promote_to_largest in reduce operations (fixes issue1663) 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 @@ -956,8 +956,7 @@ return func_with_new_name(impl, reduce_%s_impl_%d_%d % (ufunc_name, promote_to_largest, cumulative)) -descr_sum = _reduce_ufunc_impl(add) -descr_sum_promote = _reduce_ufunc_impl(add, True) +descr_sum = _reduce_ufunc_impl(add, True) descr_prod = _reduce_ufunc_impl(multiply, True) descr_max = _reduce_ufunc_impl(maximum) descr_min = _reduce_ufunc_impl(minimum) diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -496,6 +496,15 @@ @jit.unroll_safe def find_unaryop_result_dtype(space, dt, promote_to_float=False, promote_bools=False, promote_to_largest=False): +if promote_to_largest: +if dt.kind == NPY_GENBOOLLTR or dt.kind == NPY_SIGNEDLTR: +return interp_dtype.get_dtype_cache(space).w_int64dtype +elif dt.kind == NPY_UNSIGNEDLTR: +return interp_dtype.get_dtype_cache(space).w_uint64dtype +elif dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR: +return dt +else: +assert False if promote_bools and (dt.kind == NPY_GENBOOLLTR): return interp_dtype.get_dtype_cache(space).w_int8dtype if promote_to_float: @@ -507,15 +516,6 @@ if (dtype.kind == NPY_FLOATINGLTR and dtype.itemtype.get_element_size() dt.itemtype.get_element_size()): return dtype -if promote_to_largest: -if dt.kind == NPY_GENBOOLLTR or dt.kind == NPY_SIGNEDLTR: -return interp_dtype.get_dtype_cache(space).w_float64dtype -elif dt.kind == NPY_FLOATINGLTR: -return interp_dtype.get_dtype_cache(space).w_float64dtype -elif dt.kind == NPY_UNSIGNEDLTR: -return interp_dtype.get_dtype_cache(space).w_uint64dtype -else: -assert False return dt def find_dtype_for_scalar(space, w_obj, current_guess=None): 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 @@ -1344,7 +1344,7 @@ assert d[1] == 12 def test_sum(self): -from numpypy import array, zeros +from numpypy import array, zeros, float16, complex64, str_ a = array(range(5)) assert a.sum() == 10 assert a[:4].sum() == 6 @@ -1352,6 +1352,12 @@ a = array([True] * 5, bool) assert a.sum() == 5 +assert array([True, False] * 200).sum() == 200 +assert array([True, False] * 200, dtype='int8').sum() == 200 +assert array([True, False] * 200).sum(dtype='int8') == -56 +assert type(array([True, False] * 200, dtype='float16').sum()) is float16 +assert type(array([True, False] * 200, dtype='complex64').sum()) is complex64 + raises(TypeError, 'a.sum(axis=0, out=3)') raises(ValueError, 'a.sum(axis=2)') d = array(0.) @@ -1394,10 +1400,16 @@ assert (array([[1,2],[3,4]]).prod(1) == [2, 12]).all() def test_prod(self): -from numpypy import array +from numpypy import array, int_, dtype a = array(range(1, 6)) assert a.prod() == 120.0 assert a[:4].prod() == 24.0 +a = array([True, False]) +assert a.prod() == 0 +assert type(a.prod()) is int_ +a = array([True, False], dtype='uint') +assert a.prod() == 0 +assert type(a.prod()) is dtype('uint').type def test_max(self): from numpypy import array, zeros ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: adapt import library for changeset a1989cb701a7
Author: Matti Picus matti.pi...@gmail.com Branch: Changeset: r68470:69886daae534 Date: 2013-12-18 23:13 +0200 http://bitbucket.org/pypy/pypy/changeset/69886daae534/ Log:adapt import library for changeset a1989cb701a7 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 @@ -115,10 +115,11 @@ continue print Picking %s % p binaries.append((p, p.basename)) -if pypy_c.dirpath().join(libpypy-c.lib).check(): -shutil.copyfile(str(pypy_c.dirpath().join(libpypy-c.lib)), +importlib_name = 'python27.lib' +if pypy_c.dirpath().join(importlib_name).check(): +shutil.copyfile(str(pypy_c.dirpath().join(importlib_name)), str(pypydir.join('include/python27.lib'))) -print Picking %s as %s % (pypy_c.dirpath().join(libpypy-c.lib), +print Picking %s as %s % (pypy_c.dirpath().join(importlib_name), pypydir.join('include/python27.lib')) else: pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: coding convention fix
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r68471:a53125f2cdc0 Date: 2013-10-17 12:28 -0700 http://bitbucket.org/pypy/pypy/changeset/a53125f2cdc0/ Log:coding convention fix diff --git a/pypy/module/cppyy/include/capi.h b/pypy/module/cppyy/include/capi.h --- a/pypy/module/cppyy/include/capi.h +++ b/pypy/module/cppyy/include/capi.h @@ -89,11 +89,11 @@ cppyy_index_t cppyy_get_global_operator( cppyy_scope_t scope, cppyy_scope_t lc, cppyy_scope_t rc, const char* op); -/* method properties - */ +/* method properties -- */ int cppyy_is_constructor(cppyy_type_t type, cppyy_index_t idx); int cppyy_is_staticmethod(cppyy_type_t type, cppyy_index_t idx); -/* data member reflection information */ +/* data member reflection information - */ int cppyy_num_datamembers(cppyy_scope_t scope); char* cppyy_datamember_name(cppyy_scope_t scope, int datamember_index); char* cppyy_datamember_type(cppyy_scope_t scope, int datamember_index); @@ -101,7 +101,7 @@ int cppyy_datamember_index(cppyy_scope_t scope, const char* name); -/* data member properties */ +/* data member properties - */ int cppyy_is_publicdata(cppyy_type_t type, int datamember_index); int cppyy_is_staticdata(cppyy_type_t type, int datamember_index); ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: revert back to default choice of capi
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r68474:2a1f5512b630 Date: 2013-12-18 14:18 -0800 http://bitbucket.org/pypy/pypy/changeset/2a1f5512b630/ Log:revert back to default choice of capi diff --git a/pypy/module/cppyy/capi/__init__.py b/pypy/module/cppyy/capi/__init__.py --- a/pypy/module/cppyy/capi/__init__.py +++ b/pypy/module/cppyy/capi/__init__.py @@ -9,8 +9,8 @@ # the selection of the desired backend (default is Reflex). # choose C-API access method: -#from pypy.module.cppyy.capi.loadable_capi import * -from pypy.module.cppyy.capi.builtin_capi import * +from pypy.module.cppyy.capi.loadable_capi import * +#from pypy.module.cppyy.capi.builtin_capi import * from pypy.module.cppyy.capi.capi_types import C_OBJECT,\ C_NULL_TYPE, C_NULL_OBJECT diff --git a/pypy/module/cppyy/capi/builtin_capi.py b/pypy/module/cppyy/capi/builtin_capi.py --- a/pypy/module/cppyy/capi/builtin_capi.py +++ b/pypy/module/cppyy/capi/builtin_capi.py @@ -1,8 +1,8 @@ from rpython.rtyper.lltypesystem import rffi, lltype from rpython.rlib import jit -#import reflex_capi as backend -import cint_capi as backend +import reflex_capi as backend +#import cint_capi as backend from pypy.module.cppyy.capi.capi_types import C_SCOPE, C_TYPE, C_OBJECT,\ C_METHOD, C_INDEX, C_INDEX_ARRAY, WLAVC_INDEX,\ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: fix callback declaration
Author: Wim Lavrijsen wlavrij...@lbl.gov Branch: reflex-support Changeset: r68473:0744e9384dae Date: 2013-12-18 14:07 -0800 http://bitbucket.org/pypy/pypy/changeset/0744e9384dae/ Log:fix callback declaration diff --git a/pypy/module/cppyy/capi/cint_capi.py b/pypy/module/cppyy/capi/cint_capi.py --- a/pypy/module/cppyy/capi/cint_capi.py +++ b/pypy/module/cppyy/capi/cint_capi.py @@ -8,6 +8,7 @@ from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.rtyper.lltypesystem import rffi, lltype from rpython.rlib import libffi, rdynload +from rpython.tool.udir import udir from pypy.module.cppyy.capi.capi_types import C_OBJECT @@ -22,13 +23,13 @@ import commands (stat, incdir) = commands.getstatusoutput(root-config --incdir) if stat != 0: -rootincpath = [os.path.join(os.environ[ROOTSYS], include)] +rootincpath = [os.path.join(os.environ[ROOTSYS], include), py.path.local(udir)] rootlibpath = [os.path.join(os.environ[ROOTSYS], lib64), os.path.join(os.environ[ROOTSYS], lib)] else: -rootincpath = [incdir] +rootincpath = [incdir, py.path.local(udir)] rootlibpath = commands.getoutput(root-config --libdir).split() else: -rootincpath = [] +rootincpath = [py.path.local(udir)] rootlibpath = [] def identify(): @@ -422,7 +423,7 @@ from pypy.module.cpyext.api import cpython_api, CANNOT_FAIL @cpython_api([rffi.VOIDP], lltype.Void, error=CANNOT_FAIL) -def cppyy_recursive_remove(space, cppobject): +def _Py_cppyy_recursive_remove(space, cppobject): from pypy.module.cppyy.interp_cppyy import memory_regulator from pypy.module.cppyy.capi import C_OBJECT, C_NULL_OBJECT diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx b/pypy/module/cppyy/src/cintcwrapper.cxx --- a/pypy/module/cppyy/src/cintcwrapper.cxx +++ b/pypy/module/cppyy/src/cintcwrapper.cxx @@ -37,6 +37,9 @@ #include string #include utility +// for recursive_remove callback +#include pypy_macros.h + /* ROOT/CINT internals --- */ extern long G__store_struct_offset; @@ -61,12 +64,12 @@ }; // memory regulation (cppyy_recursive_remove is generated as a cpyext capi call) -extern C void cppyy_recursive_remove(void*); +extern C void _Py_cppyy_recursive_remove(void*); class Cppyy_MemoryRegulator : public TObject { public: virtual void RecursiveRemove(TObject* object) { -cppyy_recursive_remove((void*)object); +_Py_cppyy_recursive_remove((void*)object); } }; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: reapply py3k's special casing of int() results and fix buffer handling
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68476:225823af4c47 Date: 2013-12-18 15:45 -0800 http://bitbucket.org/pypy/pypy/changeset/225823af4c47/ Log:reapply py3k's special casing of int() results and fix buffer handling diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py --- a/pypy/objspace/std/longtype.py +++ b/pypy/objspace/std/longtype.py @@ -29,12 +29,10 @@ elif type(w_value) is W_LongObject: return newbigint(space, w_longtype, w_value.num) elif space.lookup(w_value, '__int__') is not None: -w_obj = space.int(w_value) -return newbigint(space, w_longtype, space.bigint_w(w_obj)) +return _from_intlike(space, w_longtype, w_value) elif space.lookup(w_value, '__trunc__') is not None: w_obj = space.trunc(w_value) -w_obj = space.int(w_obj) -return newbigint(space, w_longtype, space.bigint_w(w_obj)) +return _from_intlike(space, w_longtype, w_obj) elif space.isinstance_w(w_value, space.w_unicode): from pypy.objspace.std.unicodeobject import unicode_to_decimal_w return string_to_w_long(space, w_longtype, @@ -54,7 +52,8 @@ w_value) else: buf = space.interp_w(Buffer, w_buffer) -return string_to_w_long(space, w_longtype, buf.as_str()) +return string_to_w_long(space, w_longtype, +buf.as_str().decode('latin-1')) else: try: base = space.int_w(w_base) @@ -77,6 +76,13 @@ return string_to_w_long(space, w_longtype, s, base) +def _from_intlike(space, w_longtype, w_intlike): +w_obj = space.int(w_intlike) +if space.is_w(w_longtype, space.w_int): +return w_obj +return newbigint(space, w_longtype, space.bigint_w(w_obj)) + + def string_to_w_long(space, w_longtype, s, base=10): try: bigint = rbigint.fromstr(s, base) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: merge default
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68477:d37bd06f36fa Date: 2013-12-18 15:47 -0800 http://bitbucket.org/pypy/pypy/changeset/d37bd06f36fa/ Log:merge default diff --git a/lib_pypy/_sha1.py b/lib_pypy/_sha1.py --- a/lib_pypy/_sha1.py +++ b/lib_pypy/_sha1.py @@ -115,14 +115,14 @@ ] class sha: -An implementation of the MD5 hash function in pure Python. +An implementation of the SHA hash function in pure Python. digest_size = digestsize = 20 -block_size = 1 +block_size = 512 // 8 def __init__(self): Initialisation. - + # Initial message length in bits(!). self.length = 0 self.count = [0, 0] @@ -209,7 +209,7 @@ self.H2 = (self.H2 + C) 0x self.H3 = (self.H3 + D) 0x self.H4 = (self.H4 + E) 0x - + # Down from here all methods follow the Python Standard Library # API of the sha module. @@ -298,13 +298,13 @@ _long2bytesBigEndian(self.H3, 4) + \ _long2bytesBigEndian(self.H4, 4) -self.H0 = H0 -self.H1 = H1 +self.H0 = H0 +self.H1 = H1 self.H2 = H2 self.H3 = H3 self.H4 = H4 -self.input = input -self.count = count +self.input = input +self.count = count return digest 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 @@ -10,7 +10,7 @@ 'array': 'interp_numarray.array', 'zeros': 'interp_numarray.zeros', 'empty': 'interp_numarray.zeros', -'ones': 'interp_numarray.ones', +'empty_like': 'interp_numarray.empty_like', '_reconstruct' : 'interp_numarray._reconstruct', 'scalar' : 'interp_numarray.build_scalar', 'dot': 'interp_arrayops.dot', @@ -106,8 +106,6 @@ ('logaddexp2', 'logaddexp2'), ('real', 'real'), ('imag', 'imag'), -('ones_like', 'ones_like'), -('zeros_like', 'zeros_like'), ]: interpleveldefs[exposed] = interp_ufuncs.get(space).%s % impl diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py b/pypy/module/micronumpy/arrayimpl/concrete.py --- a/pypy/module/micronumpy/arrayimpl/concrete.py +++ b/pypy/module/micronumpy/arrayimpl/concrete.py @@ -47,7 +47,7 @@ def setslice(self, space, arr): impl = arr.implementation if impl.is_scalar(): -self.fill(impl.get_scalar_value()) +self.fill(space, impl.get_scalar_value()) return shape = shape_agreement(space, self.get_shape(), arr) if impl.storage == self.storage: @@ -100,7 +100,7 @@ tmp = self.get_real(orig_array) tmp.setslice(space, convert_to_array(space, w_value)) -def get_imag(self, orig_array): +def get_imag(self, space, orig_array): strides = self.get_strides() backstrides = self.get_backstrides() if self.dtype.is_complex_type(): @@ -110,11 +110,11 @@ impl = NonWritableArray(self.get_shape(), self.dtype, self.order, strides, backstrides) if not self.dtype.is_flexible_type(): -impl.fill(self.dtype.box(0)) +impl.fill(space, self.dtype.box(0)) return impl def set_imag(self, space, orig_array, w_value): -tmp = self.get_imag(orig_array) +tmp = self.get_imag(space, orig_array) tmp.setslice(space, convert_to_array(space, w_value)) # applevel get/setitem --- @@ -357,7 +357,7 @@ self.get_backstrides(), self.get_shape()) -def fill(self, box): +def fill(self, space, box): self.dtype.itemtype.fill(self.storage, self.dtype.get_size(), box, 0, self.size, 0) @@ -435,8 +435,8 @@ def base(self): return self.orig_arr -def fill(self, box): -loop.fill(self, box.convert_to(self.dtype)) +def fill(self, space, box): +loop.fill(self, box.convert_to(space, self.dtype)) def create_iter(self, shape=None, backward_broadcast=False, require_index=False): if shape is not None and \ diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py b/pypy/module/micronumpy/arrayimpl/scalar.py --- a/pypy/module/micronumpy/arrayimpl/scalar.py +++ b/pypy/module/micronumpy/arrayimpl/scalar.py @@ -54,8 +54,7 @@ return self.value def set_scalar_value(self, w_val): -assert isinstance(w_val, W_GenericBox) -self.value = w_val.convert_to(self.dtype) +self.value = w_val def copy(self, space): scalar = Scalar(self.dtype) @@ -96,12 +95,12 @@ ','.join([str(x) for x in w_arr.get_shape()],
[pypy-commit] pypy py3k: merge upstream
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68478:55a82ced3b8a Date: 2013-12-18 15:48 -0800 http://bitbucket.org/pypy/pypy/changeset/55a82ced3b8a/ Log:merge upstream diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py --- a/lib-python/3/datetime.py +++ b/lib-python/3/datetime.py @@ -40,9 +40,9 @@ # for all computations. See the book for algorithms for converting between # proleptic Gregorian ordinals and many other calendar systems. -_DAYS_IN_MONTH = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] +_DAYS_IN_MONTH = [-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] -_DAYS_BEFORE_MONTH = [None] +_DAYS_BEFORE_MONTH = [-1] dbm = 0 for dim in _DAYS_IN_MONTH[1:]: _DAYS_BEFORE_MONTH.append(dbm) @@ -806,7 +806,6 @@ month = self._month if day is None: day = self._day -year, month, day = _check_date_fields(year, month, day) return date(year, month, day) # Comparisons of date objects with other. @@ -1270,8 +1269,6 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -hour, minute, second, microsecond = _check_time_fields(hour, minute, second, microsecond) -_check_tzinfo_arg(tzinfo) return time(hour, minute, second, microsecond, tzinfo) def __bool__(self): @@ -1486,9 +1483,6 @@ microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo -year, month, day = _check_date_fields(year, month, day) -hour, minute, second, microsecond = _check_time_fields(hour, minute, second, microsecond) -_check_tzinfo_arg(tzinfo) return datetime(year, month, day, hour, minute, second, microsecond, tzinfo) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: merge default
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68475:c9fe258e0217 Date: 2013-12-18 15:40 -0800 http://bitbucket.org/pypy/pypy/changeset/c9fe258e0217/ Log:merge default diff --git a/pypy/module/__builtin__/app_operation.py b/pypy/module/__builtin__/app_operation.py --- a/pypy/module/__builtin__/app_operation.py +++ b/pypy/module/__builtin__/app_operation.py @@ -2,8 +2,8 @@ def bin(x): Return the binary representation of an integer. -x = operator.index(x) -return x.__format__(#b) +value = operator.index(x) +return value.__format__(#b) def oct(x): Return the octal representation of an integer. diff --git a/pypy/module/__builtin__/test/test_builtin.py b/pypy/module/__builtin__/test/test_builtin.py --- a/pypy/module/__builtin__/test/test_builtin.py +++ b/pypy/module/__builtin__/test/test_builtin.py @@ -84,6 +84,15 @@ assert bin(-2) == -0b10 assert bin(Foo()) == 0b100 raises(TypeError, bin, 0.) +class C(object): +def __index__(self): +return 42 +assert bin(C()) == bin(42) +class D(object): +def __int__(self): +return 42 +exc = raises(TypeError, bin, D()) +assert index in exc.value.message def test_oct(self): class Foo: diff --git a/pypy/module/_cffi_backend/cbuffer.py b/pypy/module/_cffi_backend/cbuffer.py --- a/pypy/module/_cffi_backend/cbuffer.py +++ b/pypy/module/_cffi_backend/cbuffer.py @@ -5,7 +5,9 @@ from pypy.interpreter.typedef import TypeDef, make_weakref_descr from pypy.module._cffi_backend import cdataobj, ctypeptr, ctypearray +from rpython.rtyper.annlowlevel import llstr from rpython.rtyper.lltypesystem import rffi +from rpython.rtyper.lltypesystem.rstr import copy_string_to_raw class LLBuffer(RWBuffer): @@ -34,8 +36,7 @@ def setslice(self, start, string): raw_cdata = rffi.ptradd(self.raw_cdata, start) -for i in range(len(string)): -raw_cdata[i] = string[i] +copy_string_to_raw(llstr(string), raw_cdata, 0, len(string)) class MiniBuffer(W_Root): diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py --- a/pypy/module/_cffi_backend/cdataobj.py +++ b/pypy/module/_cffi_backend/cdataobj.py @@ -206,8 +206,7 @@ w_value.get_array_length() == length): # fast path: copying from exactly the correct type s = w_value._cdata -for i in range(ctitemsize * length): -cdata[i] = s[i] +rffi.c_memcpy(cdata, s, ctitemsize * length) keepalive_until_here(w_value) return # @@ -259,7 +258,6 @@ space = self.space if isinstance(w_other, W_CData): from pypy.module._cffi_backend import ctypeptr, ctypearray -from pypy.module._cffi_backend import ctypevoid ct = w_other.ctype if isinstance(ct, ctypearray.W_CTypeArray): ct = ct.ctptr diff --git a/pypy/module/math/app_math.py b/pypy/module/math/app_math.py --- a/pypy/module/math/app_math.py +++ b/pypy/module/math/app_math.py @@ -1,7 +1,9 @@ import sys def factorial(x): -Find x!. +factorial(x) - Integral + +Find x!. Raise a ValueError if x is negative or non-integral. if isinstance(x, float): fl = int(x) if fl != x: @@ -18,15 +20,15 @@ res *= i return res -#Experimentally this gap seems good -gap = max(100, x7) +# Experimentally this gap seems good +gap = max(100, x 7) def _fac_odd(low, high): -if low+gap = high: +if low + gap = high: t = 1 for i in range(low, high, 2): t *= i return t - + mid = ((low + high) 1) | 1 return _fac_odd(low, mid) * _fac_odd(mid, high) diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py b/pypy/module/micronumpy/arrayimpl/concrete.py --- a/pypy/module/micronumpy/arrayimpl/concrete.py +++ b/pypy/module/micronumpy/arrayimpl/concrete.py @@ -502,3 +502,6 @@ def getlength(self): return self.impl.size + +def get_raw_address(self): +return self.impl.storage diff --git a/pypy/module/micronumpy/arrayimpl/scalar.py b/pypy/module/micronumpy/arrayimpl/scalar.py --- a/pypy/module/micronumpy/arrayimpl/scalar.py +++ b/pypy/module/micronumpy/arrayimpl/scalar.py @@ -132,6 +132,12 @@ if space.isinstance_w(w_idx, space.w_tuple): if space.len_w(w_idx) == 0: return self.get_scalar_value() +if space.is_none(w_idx): +new_shape = [1] +arr = W_NDimArray.from_shape(space, new_shape, self.dtype) +arr_iter = arr.create_iter(new_shape) +arr_iter.setitem(self.value) +return arr raise OperationError(space.w_IndexError,
[pypy-commit] pypy py3k: fix -Ojit translation: kill stray/misplaced lines from a merge
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68480:46e0449759bb Date: 2013-12-18 17:53 -0800 http://bitbucket.org/pypy/pypy/changeset/46e0449759bb/ Log:fix -Ojit translation: kill stray/misplaced lines from a merge diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py --- a/pypy/interpreter/pyframe.py +++ b/pypy/interpreter/pyframe.py @@ -576,8 +576,6 @@ Initialize cellvars from self.locals_stack_w. -if self.cells is None: -return args_to_copy = self.pycode._args_as_cellvars for i in range(len(args_to_copy)): argnum = args_to_copy[i] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: test/fix promote_to_largest wrt 32bit, though demonstrates another problem
Author: Brian Kearns bdkea...@gmail.com Branch: Changeset: r68481:84c4bc069470 Date: 2013-12-18 21:27 -0500 http://bitbucket.org/pypy/pypy/changeset/84c4bc069470/ Log:test/fix promote_to_largest wrt 32bit, though demonstrates another problem diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py --- a/pypy/module/micronumpy/interp_ufuncs.py +++ b/pypy/module/micronumpy/interp_ufuncs.py @@ -498,13 +498,14 @@ promote_bools=False, promote_to_largest=False): if promote_to_largest: if dt.kind == NPY_GENBOOLLTR or dt.kind == NPY_SIGNEDLTR: -return interp_dtype.get_dtype_cache(space).w_int64dtype +if dt.get_size() * 8 LONG_BIT: +return interp_dtype.get_dtype_cache(space).w_longdtype elif dt.kind == NPY_UNSIGNEDLTR: -return interp_dtype.get_dtype_cache(space).w_uint64dtype -elif dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR: -return dt +if dt.get_size() * 8 LONG_BIT: +return interp_dtype.get_dtype_cache(space).w_ulongdtype else: -assert False +assert dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR +return dt if promote_bools and (dt.kind == NPY_GENBOOLLTR): return interp_dtype.get_dtype_cache(space).w_int8dtype if promote_to_float: 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 @@ -1404,12 +1404,14 @@ a = array(range(1, 6)) assert a.prod() == 120.0 assert a[:4].prod() == 24.0 -a = array([True, False]) -assert a.prod() == 0 -assert type(a.prod()) is int_ -a = array([True, False], dtype='uint') -assert a.prod() == 0 -assert type(a.prod()) is dtype('uint').type +for dt in ['bool', 'int8', 'uint8', 'int16', 'uint16']: +a = array([True, False], dtype=dt) +assert a.prod() == 0 +assert a.prod().dtype is dtype('uint' if dt[0] == 'u' else 'int') +for dt in ['l', 'L', 'q', 'Q', 'e', 'f', 'd', 'F', 'D']: +a = array([True, False], dtype=dt) +assert a.prod() == 0 +assert a.prod().dtype is dtype(dt) def test_max(self): from numpypy import array, zeros ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: 2to3ish
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68482:231446df54bb Date: 2013-12-18 19:30 -0800 http://bitbucket.org/pypy/pypy/changeset/231446df54bb/ Log:2to3ish diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py --- a/pypy/module/micronumpy/test/test_scalar.py +++ b/pypy/module/micronumpy/test/test_scalar.py @@ -22,10 +22,10 @@ import numpy as np assert int(np.str_('12')) == 12 exc = raises(ValueError, int(np.str_('abc'))) -assert exc.value.message.startswith('invalid literal for int()') -assert oct(np.int32(11)) == '013' -assert oct(np.float32(11.6)) == '013' -assert oct(np.complex64(11-12j)) == '013' +assert str(exc.value).startswith('invalid literal for int()') +assert oct(np.int32(11)) == '0o13' +assert oct(np.float32(11.6)) == '0o13' +assert oct(np.complex64(11-12j)) == '0o13' assert hex(np.int32(11)) == '0xb' assert hex(np.float32(11.6)) == '0xb' assert hex(np.complex64(11-12j)) == '0xb' @@ -43,7 +43,7 @@ except ImportError: # running on dummy module from numpy import scalar -from cPickle import loads, dumps +from pickle import loads, dumps i = dtype('int32').type(1337) f = dtype('float64').type(13.37) c = dtype('complex128').type(13 + 37.j) @@ -98,10 +98,10 @@ def test_buffer(self): import numpy as np a = np.int32(123) -b = buffer(a) -assert type(b) is buffer +b = memoryview(a) +assert type(b) is memoryview a = np.string_('abc') -b = buffer(a) +b = memoryview(a) assert str(b) == a def test_squeeze(self): @@ -137,7 +137,7 @@ import sys s = np.dtype('int64').type(12) exc = raises(ValueError, s.view, 'int8') -assert exc.value[0] == new type not compatible with array. +assert str(exc.value) == new type not compatible with array. t = s.view('double') assert type(t) is np.double assert t 7e-323 @@ -146,7 +146,7 @@ assert 0 t.real 1 assert t.imag == 0 exc = raises(TypeError, s.view, 'string') -assert exc.value[0] == data-type must not be 0-sized +assert str(exc.value) == data-type must not be 0-sized t = s.view('S8') assert type(t) is np.string_ assert t == '\x0c' ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: 2to3
Author: Philip Jenvey pjen...@underboss.org Branch: py3k Changeset: r68484:5547c4821d09 Date: 2013-12-18 20:17 -0800 http://bitbucket.org/pypy/pypy/changeset/5547c4821d09/ Log:2to3 diff --git a/pypy/module/__builtin__/test/test_builtin.py b/pypy/module/__builtin__/test/test_builtin.py --- a/pypy/module/__builtin__/test/test_builtin.py +++ b/pypy/module/__builtin__/test/test_builtin.py @@ -92,7 +92,7 @@ def __int__(self): return 42 exc = raises(TypeError, bin, D()) -assert index in exc.value.message +assert index in str(exc.value) def test_oct(self): class Foo: diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py --- a/pypy/objspace/std/test/test_longobject.py +++ b/pypy/objspace/std/test/test_longobject.py @@ -301,7 +301,7 @@ def test_long_before_string(self): class A(str): -def __long__(self): +def __int__(self): return 42 assert int(A('abc')) == 42 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit