[pypy-commit] pypy numpy-ufuncs: Make the operators on an array use the ufuncs internally.

2011-07-21 Thread alex_gaynor
Author: Alex Gaynor 
Branch: numpy-ufuncs
Changeset: r45789:cb06fc29e57c
Date: 2011-07-21 00:38 -0700
http://bitbucket.org/pypy/pypy/changeset/cb06fc29e57c/

Log:Make the operators on an array use the ufuncs internally.

diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -3,7 +3,7 @@
 It should not be imported by the module itself
 """
 
-from pypy.module.micronumpy.interp_numarray import FloatWrapper, SingleDimArray
+from pypy.module.micronumpy.interp_numarray import FloatWrapper, 
SingleDimArray, BaseArray
 
 class BogusBytecode(Exception):
 pass
@@ -18,6 +18,14 @@
 def wrap(self, x):
 return x
 
+def issequence_w(self, w_obj):
+# Completley wrong in the general case, but good enough for this.
+return isinstance(w_obj, BaseArray)
+
+def float_w(self, w_obj):
+assert isinstance(w_obj, float)
+return w_obj
+
 def numpy_compile(bytecode, array_size):
 space = TrivialSpace()
 stack = []
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
@@ -2,6 +2,8 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
+from pypy.module.micronumpy.interp_support import Signature
+from pypy.module.micronumpy import interp_ufuncs
 from pypy.objspace.std.floatobject import float2string as float2string_orig
 from pypy.rlib import jit
 from pypy.rlib.rfloat import DTSF_STR_PRECISION
@@ -24,16 +26,6 @@
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 
-class Signature(object):
-def __init__(self):
-self.transitions = {}
-
-def transition(self, target):
-if target in self.transitions:
-return self.transitions[target]
-self.transitions[target] = new = Signature()
-return new
-
 def pos(v):
 return v
 def neg(v):
@@ -42,16 +34,8 @@
 return abs(v)
 def add(v1, v2):
 return v1 + v2
-def sub(v1, v2):
-return v1 - v2
 def mul(v1, v2):
 return v1 * v2
-def div(v1, v2):
-return v1 / v2
-def power(v1, v2):
-return math.pow(v1, v2)
-def mod(v1, v2):
-return math.fmod(v1, v2)
 def maximum(v1, v2):
 return max(v1, v2)
 def minimum(v1, v2):
@@ -89,51 +73,30 @@
 descr_neg = _unop_impl(neg)
 descr_abs = _unop_impl(absolute)
 
-def _binop_impl(function):
-signature = Signature()
+def _binop_impl(w_ufunc):
 def impl(self, space, w_other):
-w_other = convert_to_array(space, w_other)
-new_sig = self.signature.transition(signature)
-res = Call2(
-function,
-self,
-w_other,
-new_sig.transition(w_other.signature)
-)
-w_other.invalidates.append(res)
-self.invalidates.append(res)
-return space.wrap(res)
-return func_with_new_name(impl, "binop_%s_impl" % function.__name__)
+return w_ufunc(space, self, w_other)
+return func_with_new_name(impl, "binop_%s_impl" % w_ufunc.__name__)
 
-descr_add = _binop_impl(add)
-descr_sub = _binop_impl(sub)
-descr_mul = _binop_impl(mul)
-descr_div = _binop_impl(div)
-descr_pow = _binop_impl(power)
-descr_mod = _binop_impl(mod)
+descr_add = _binop_impl(interp_ufuncs.add)
+descr_sub = _binop_impl(interp_ufuncs.subtract)
+descr_mul = _binop_impl(interp_ufuncs.multiply)
+descr_div = _binop_impl(interp_ufuncs.divide)
+descr_pow = _binop_impl(interp_ufuncs.power)
+descr_mod = _binop_impl(interp_ufuncs.mod)
 
-def _binop_right_impl(function):
-signature = Signature()
+def _binop_right_impl(w_ufunc):
 def impl(self, space, w_other):
-new_sig = self.signature.transition(signature)
 w_other = FloatWrapper(space.float_w(w_other))
-res = Call2(
-function,
-w_other,
-self,
-new_sig.transition(w_other.signature)
-)
-self.invalidates.append(res)
-return space.wrap(res)
-return func_with_new_name(impl,
-  "binop_right_%s_impl" % function.__name__)
+return w_ufunc(space, w_other, self)
+return func_with_new_name(impl, "binop_right_%s_impl" % 
w_ufunc.__name__)
 
-descr_radd = _binop_right_impl(add)
-descr_rsub = _binop_right_impl(sub)
-descr_rmul = _binop_right_impl(mul)
-descr_rdiv = _binop_right_impl(div)
-descr_rpow = _binop_right_impl(power)
-descr_rmod = _binop_right_impl(mod)
+descr_radd 

[pypy-commit] pypy numpy-ufuncs: Closing about to be merged branch.

2011-07-21 Thread alex_gaynor
Author: Alex Gaynor 
Branch: numpy-ufuncs
Changeset: r45790:2722bcb465c0
Date: 2011-07-21 00:44 -0700
http://bitbucket.org/pypy/pypy/changeset/2722bcb465c0/

Log:Closing about to be merged branch.

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Merged numpy-ufuncs into trunk.

2011-07-21 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r45791:a3f9ed7d37a7
Date: 2011-07-21 00:44 -0700
http://bitbucket.org/pypy/pypy/changeset/a3f9ed7d37a7/

Log:Merged numpy-ufuncs into trunk.

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
@@ -15,14 +15,19 @@
 # ufuncs
 'abs': 'interp_ufuncs.absolute',
 'absolute': 'interp_ufuncs.absolute',
+'add': 'interp_ufuncs.add',
 'copysign': 'interp_ufuncs.copysign',
+'divide': 'interp_ufuncs.divide',
 'exp': 'interp_ufuncs.exp',
+'fabs': 'interp_ufuncs.fabs',
 'floor': 'interp_ufuncs.floor',
 'maximum': 'interp_ufuncs.maximum',
 'minimum': 'interp_ufuncs.minimum',
+'multiply': 'interp_ufuncs.multiply',
 'negative': 'interp_ufuncs.negative',
 'reciprocal': 'interp_ufuncs.reciprocal',
 'sign': 'interp_ufuncs.sign',
+'subtract': 'interp_ufuncs.subtract',
 'sin': 'interp_ufuncs.sin',
 'cos': 'interp_ufuncs.cos',
 'tan': 'interp_ufuncs.tan',
diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -3,7 +3,7 @@
 It should not be imported by the module itself
 """
 
-from pypy.module.micronumpy.interp_numarray import FloatWrapper, SingleDimArray
+from pypy.module.micronumpy.interp_numarray import FloatWrapper, 
SingleDimArray, BaseArray
 
 class BogusBytecode(Exception):
 pass
@@ -18,6 +18,14 @@
 def wrap(self, x):
 return x
 
+def issequence_w(self, w_obj):
+# Completley wrong in the general case, but good enough for this.
+return isinstance(w_obj, BaseArray)
+
+def float_w(self, w_obj):
+assert isinstance(w_obj, float)
+return w_obj
+
 def numpy_compile(bytecode, array_size):
 space = TrivialSpace()
 stack = []
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
@@ -2,6 +2,8 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
+from pypy.module.micronumpy.interp_support import Signature
+from pypy.module.micronumpy import interp_ufuncs
 from pypy.objspace.std.floatobject import float2string as float2string_orig
 from pypy.rlib import jit
 from pypy.rlib.rfloat import DTSF_STR_PRECISION
@@ -24,16 +26,6 @@
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 
-class Signature(object):
-def __init__(self):
-self.transitions = {}
-
-def transition(self, target):
-if target in self.transitions:
-return self.transitions[target]
-self.transitions[target] = new = Signature()
-return new
-
 def pos(v):
 return v
 def neg(v):
@@ -42,16 +34,8 @@
 return abs(v)
 def add(v1, v2):
 return v1 + v2
-def sub(v1, v2):
-return v1 - v2
 def mul(v1, v2):
 return v1 * v2
-def div(v1, v2):
-return v1 / v2
-def power(v1, v2):
-return math.pow(v1, v2)
-def mod(v1, v2):
-return math.fmod(v1, v2)
 def maximum(v1, v2):
 return max(v1, v2)
 def minimum(v1, v2):
@@ -89,51 +73,30 @@
 descr_neg = _unop_impl(neg)
 descr_abs = _unop_impl(absolute)
 
-def _binop_impl(function):
-signature = Signature()
+def _binop_impl(w_ufunc):
 def impl(self, space, w_other):
-w_other = convert_to_array(space, w_other)
-new_sig = self.signature.transition(signature)
-res = Call2(
-function,
-self,
-w_other,
-new_sig.transition(w_other.signature)
-)
-w_other.invalidates.append(res)
-self.invalidates.append(res)
-return space.wrap(res)
-return func_with_new_name(impl, "binop_%s_impl" % function.__name__)
+return w_ufunc(space, self, w_other)
+return func_with_new_name(impl, "binop_%s_impl" % w_ufunc.__name__)
 
-descr_add = _binop_impl(add)
-descr_sub = _binop_impl(sub)
-descr_mul = _binop_impl(mul)
-descr_div = _binop_impl(div)
-descr_pow = _binop_impl(power)
-descr_mod = _binop_impl(mod)
+descr_add = _binop_impl(interp_ufuncs.add)
+descr_sub = _binop_impl(interp_ufuncs.subtract)
+descr_mul = _binop_impl(interp_ufuncs.multiply)
+descr_div = _binop_impl(interp_ufuncs.divide)
+descr_pow = _binop_impl(interp_ufuncs.power)
+descr_mod = _binop_impl(interp_ufuncs.mod)
 
-def _binop_right_impl(function):
-signature = Signature()
+def _binop_right_impl(w_ufunc

[pypy-commit] pypy numpy-setslice: improve tests

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: numpy-setslice
Changeset: r45792:4ee6a8782003
Date: 2011-07-21 09:51 +0200
http://bitbucket.org/pypy/pypy/changeset/4ee6a8782003/

Log:improve tests

diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -256,13 +256,16 @@
 step = NonConstant(3)
 ar = SingleDimArray(step*i)
 ar2 = SingleDimArray(i)
-ar.setslice(space, 0, step*i, step, i, ar2)
+ar2.storage[1] = 5.5
+ar.setslice(space, 0, step*i, step, i, ar2.descr_add(space, ar2))
 return ar.get_concrete().storage[3]
 
 result = self.meta_interp(f, [5], listops=True, backendopt=True)
-self.check_loops({'getarrayitem_raw': 1,
+self.check_loops({'getarrayitem_raw': 2,
+  'float_add' : 1,
   'setarrayitem_raw': 1, 'int_add': 2,
   'int_lt': 1, 'guard_true': 1, 'jump': 1})
+assert result == 11.0
 
 class TestTranslation(object):
 def test_compile(self):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge numpy-slice

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45793:fb245ad56f79
Date: 2011-07-21 09:54 +0200
http://bitbucket.org/pypy/pypy/changeset/fb245ad56f79/

Log:merge numpy-slice

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
@@ -23,6 +23,8 @@
  reds = ['result_size', 'i', 'self', 'result'])
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
+slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
+slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
 
 class Signature(object):
 def __init__(self):
@@ -288,10 +290,18 @@
 res = SingleDimSlice(start, stop, step, slice_length, self, 
self.signature.transition(SingleDimSlice.static_signature))
 return space.wrap(res)
 
-@unwrap_spec(item=int, value=float)
-def descr_setitem(self, space, item, value):
+def descr_setitem(self, space, w_idx, w_value):
+# TODO: indexing by tuples and lists
 self.invalidated()
-return self.get_concrete().descr_setitem(space, item, value)
+start, stop, step, slice_length = space.decode_index4(w_idx,
+  self.find_size())
+if step == 0:
+# Single index
+self.get_concrete().setitem(start,
+  space.float_w(w_value))
+else:
+self.get_concrete().setslice(space, start, stop, step, 
+   slice_length, w_value)
 
 def descr_mean(self, space):
 return 
space.wrap(space.float_w(self.descr_sum(space))/self.find_size())
@@ -440,8 +450,8 @@
 return self.parent.getitem(self.calc_index(item))
 
 @unwrap_spec(item=int, value=float)
-def descr_setitem(self, space, item, value):
-return self.parent.descr_setitem(space, self.calc_index(item), value)
+def setitem(self, item, value):
+return self.parent.setitem(self.calc_index(item), value)
 
 def descr_len(self, space):
 return space.wrap(self.find_size())
@@ -455,14 +465,58 @@
 
 def __init__(self, start, stop, step, slice_length, parent, signature):
 ViewArray.__init__(self, parent, signature)
+if isinstance(parent, SingleDimSlice):
+self.start = parent.calc_index(start)
+self.stop = parent.calc_index(stop)
+self.step = parent.step * step
+self.parent = parent.parent
+else:
 self.start = start
 self.stop = stop
 self.step = step
+self.parent = parent
 self.size = slice_length
 
 def find_size(self):
 return self.size
 
+def _sliceloop1(self, start, stop, step, arr):
+storage = self.parent.storage
+signature = Signature()
+new_sig = self.signature.transition(signature)
+i = start
+j = 0
+while i < stop:
+slice_driver1.jit_merge_point(signature=signature, self=self,
+step=step, stop=stop, i=i, j=j, arr=arr)
+storage[i] = arr.eval(j)
+j += 1
+i += step
+
+def _sliceloop2(self, start, stop, step, arr):
+storage = self.parent.storage
+signature = Signature()
+new_sig = self.signature.transition(signature)
+i = start
+j = 0
+while i > stop:
+slice_driver2.jit_merge_point(signature=signature, self=self,
+step=step, stop=stop, i=i, j=j, arr=arr)
+storage[i] = arr.eval(j)
+j += 1
+i += step
+
+def setslice(self, space, start, stop, step, slice_length, arr):
+arr = convert_to_array(space, arr)
+start = self.calc_index(start)
+if stop != -1:
+stop = self.calc_index(stop)
+step = self.step * step
+if step > 0:
+self._sliceloop1(start, stop, step, arr)
+else:
+self._sliceloop2(start, stop, step, arr)
+
 def calc_index(self, item):
 return (self.start + item * self.step)
 
@@ -486,7 +540,7 @@
 def eval(self, i):
 return self.storage[i]
 
-def getindex(self, space, item):
+def getindex(self, item):
 if item >= self.size:
 raise operationerrfmt(space.w_IndexError,
   '%d above array size', item)
@@ -504,11 +558,44 @@
 return self.storage[item]
 
 @unwrap_spec(item=int, value=float)
-def descr_setitem(self, space, item, value):
-item = self.getindex(space, item)
+def setitem(self, item, value):
+item = self.getindex(item)
 self.invalidated()
 self.storage[item

[pypy-commit] pypy numpy-setslice: close merged branch

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: numpy-setslice
Changeset: r45794:bb33f506f1a2
Date: 2011-07-21 09:54 +0200
http://bitbucket.org/pypy/pypy/changeset/bb33f506f1a2/

Log:close merged branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge default

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45795:95a8a9907969
Date: 2011-07-21 09:55 +0200
http://bitbucket.org/pypy/pypy/changeset/95a8a9907969/

Log:merge default

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
@@ -15,14 +15,19 @@
 # ufuncs
 'abs': 'interp_ufuncs.absolute',
 'absolute': 'interp_ufuncs.absolute',
+'add': 'interp_ufuncs.add',
 'copysign': 'interp_ufuncs.copysign',
+'divide': 'interp_ufuncs.divide',
 'exp': 'interp_ufuncs.exp',
+'fabs': 'interp_ufuncs.fabs',
 'floor': 'interp_ufuncs.floor',
 'maximum': 'interp_ufuncs.maximum',
 'minimum': 'interp_ufuncs.minimum',
+'multiply': 'interp_ufuncs.multiply',
 'negative': 'interp_ufuncs.negative',
 'reciprocal': 'interp_ufuncs.reciprocal',
 'sign': 'interp_ufuncs.sign',
+'subtract': 'interp_ufuncs.subtract',
 'sin': 'interp_ufuncs.sin',
 'cos': 'interp_ufuncs.cos',
 'tan': 'interp_ufuncs.tan',
diff --git a/pypy/module/micronumpy/compile.py 
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -3,7 +3,7 @@
 It should not be imported by the module itself
 """
 
-from pypy.module.micronumpy.interp_numarray import FloatWrapper, SingleDimArray
+from pypy.module.micronumpy.interp_numarray import FloatWrapper, 
SingleDimArray, BaseArray
 
 class BogusBytecode(Exception):
 pass
@@ -18,6 +18,14 @@
 def wrap(self, x):
 return x
 
+def issequence_w(self, w_obj):
+# Completley wrong in the general case, but good enough for this.
+return isinstance(w_obj, BaseArray)
+
+def float_w(self, w_obj):
+assert isinstance(w_obj, float)
+return w_obj
+
 def numpy_compile(bytecode, array_size):
 space = TrivialSpace()
 stack = []
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
@@ -2,6 +2,8 @@
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
+from pypy.module.micronumpy.interp_support import Signature
+from pypy.module.micronumpy import interp_ufuncs
 from pypy.objspace.std.floatobject import float2string as float2string_orig
 from pypy.rlib import jit
 from pypy.rlib.rfloat import DTSF_STR_PRECISION
@@ -26,16 +28,6 @@
 slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
 slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
 
-class Signature(object):
-def __init__(self):
-self.transitions = {}
-
-def transition(self, target):
-if target in self.transitions:
-return self.transitions[target]
-self.transitions[target] = new = Signature()
-return new
-
 def pos(v):
 return v
 def neg(v):
@@ -44,16 +36,8 @@
 return abs(v)
 def add(v1, v2):
 return v1 + v2
-def sub(v1, v2):
-return v1 - v2
 def mul(v1, v2):
 return v1 * v2
-def div(v1, v2):
-return v1 / v2
-def power(v1, v2):
-return math.pow(v1, v2)
-def mod(v1, v2):
-return math.fmod(v1, v2)
 def maximum(v1, v2):
 return max(v1, v2)
 def minimum(v1, v2):
@@ -91,51 +75,30 @@
 descr_neg = _unop_impl(neg)
 descr_abs = _unop_impl(absolute)
 
-def _binop_impl(function):
-signature = Signature()
+def _binop_impl(w_ufunc):
 def impl(self, space, w_other):
-w_other = convert_to_array(space, w_other)
-new_sig = self.signature.transition(signature)
-res = Call2(
-function,
-self,
-w_other,
-new_sig.transition(w_other.signature)
-)
-w_other.invalidates.append(res)
-self.invalidates.append(res)
-return space.wrap(res)
-return func_with_new_name(impl, "binop_%s_impl" % function.__name__)
+return w_ufunc(space, self, w_other)
+return func_with_new_name(impl, "binop_%s_impl" % w_ufunc.__name__)
 
-descr_add = _binop_impl(add)
-descr_sub = _binop_impl(sub)
-descr_mul = _binop_impl(mul)
-descr_div = _binop_impl(div)
-descr_pow = _binop_impl(power)
-descr_mod = _binop_impl(mod)
+descr_add = _binop_impl(interp_ufuncs.add)
+descr_sub = _binop_impl(interp_ufuncs.subtract)
+descr_mul = _binop_impl(interp_ufuncs.multiply)
+descr_div = _binop_impl(interp_ufuncs.divide)
+descr_pow = _binop_impl(interp_ufuncs.power)
+descr_mod = _binop_impl(interp_ufuncs.mod)
 
-def _binop_right_impl(function):
-signature = Signature

[pypy-commit] pypy default: that was easy, fix arg usage

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45796:065c98a10f0d
Date: 2011-07-21 10:22 +0200
http://bitbucket.org/pypy/pypy/changeset/065c98a10f0d/

Log:that was easy, fix arg usage

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -37,7 +37,7 @@
 return self._is_guard
 
 def repr(self):
-args = self.getargs()
+args = self.args
 if self.descr is not None:
 args.append('descr=%s' % self.descr)
 arglist = ', '.join(args)
@@ -145,7 +145,7 @@
 if operations[0].name == 'debug_merge_point':
 self.inline_level = int(operations[0].args[0])
 m = re.search('\w]+)\. file \'(.+?)\'\. line 
(\d+)> #(\d+) (\w+)',
- operations[0].getarg(1))
+ operations[0].args[1])
 if m is None:
 # a non-code loop, like StrLiteralSearch or something
 self.bytecode_name = operations[0].args[1]
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: improve display a bit and fix the test

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45797:e03df75209a9
Date: 2011-07-21 10:25 +0200
http://bitbucket.org/pypy/pypy/changeset/e03df75209a9/

Log:improve display a bit and fix the test

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -148,7 +148,7 @@
  operations[0].args[1])
 if m is None:
 # a non-code loop, like StrLiteralSearch or something
-self.bytecode_name = operations[0].args[1]
+self.bytecode_name = operations[0].args[1][1:-1]
 else:
 self.name, self.filename, lineno, bytecode_no, 
self.bytecode_name = m.groups()
 self.startlineno = int(lineno)
diff --git a/pypy/tool/jitlogparser/test/test_parser.py 
b/pypy/tool/jitlogparser/test/test_parser.py
--- a/pypy/tool/jitlogparser/test/test_parser.py
+++ b/pypy/tool/jitlogparser/test/test_parser.py
@@ -181,7 +181,7 @@
 """)
 ops = Function.from_operations(loop.operations, LoopStorage())
 chunk = ops.chunks[0]
-assert chunk.bytecode_name == 'StrLiteralSearch'
+assert chunk.bytecode_name.startswith('StrLiteralSearch')
 
 def test_parsing_assembler():
 backend_dump = 
"554889E5534154415541564157488DA5488B042590C5540148C7042590C5540148898570FF488B042598C5540148C7042598C5540148898568FF488B0425A0C5540148C70425A0C5540148898560FF488B0425A8C5540148C70425A8C5540148898558FF4C8B3C2550525B0149BB30E06C96FC7F4D8B334983C60149BB30E06C96FC7F4D89334981FF10270F8D4983C7014C8B342580F76A024983EE014C89342580F76A024983FE000F8CE9AEFF488B042588F76A024829E0483B042580EC3C01760D49BB05F30894FC7F41FFD3554889E5534154415541564157488DA550FF4889BD70FF4889B568FF48899560FF48898D58FF4D89C7E954FF49BB00F00894FC7F41FFD34440484C3D03030049BB00F00894FC7F41FFD34440484C3D07030400"
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: cleanup

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45798:6bc10a129273
Date: 2011-07-21 10:32 +0200
http://bitbucket.org/pypy/pypy/changeset/6bc10a129273/

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
@@ -260,8 +260,7 @@
   self.find_size())
 if step == 0:
 # Single index
-self.get_concrete().setitem(start,
-  space.float_w(w_value))
+self.get_concrete().setitem(start, space.float_w(w_value))
 else:
 self.get_concrete().setslice(space, start, stop, step, 
slice_length, w_value)
@@ -503,55 +502,37 @@
 def eval(self, i):
 return self.storage[i]
 
-def getindex(self, item):
-if item >= self.size:
-raise operationerrfmt(space.w_IndexError,
-  '%d above array size', item)
-if item < 0:
-item += self.size
-if item < 0:
-raise operationerrfmt(space.w_IndexError,
-  '%d below zero', item)
-return item
-
 def descr_len(self, space):
 return space.wrap(self.size)
 
 def getitem(self, item):
 return self.storage[item]
 
-@unwrap_spec(item=int, value=float)
 def setitem(self, item, value):
-item = self.getindex(item)
 self.invalidated()
 self.storage[item] = value
 
 def _sliceloop1(self, start, stop, step, arr):
-signature = Signature()
-new_sig = self.signature.transition(signature)
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=signature, self=self,
+slice_driver1.jit_merge_point(signature=self.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 self.storage[i] = arr.eval(j)
 j += 1
 i += step
 
 def _sliceloop2(self, start, stop, step, arr):
-signature = Signature()
-new_sig = self.signature.transition(signature)
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=signature, self=self,
+slice_driver2.jit_merge_point(signature=self.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 self.storage[i] = arr.eval(j)
 j += 1
 i += step
 
 def setslice(self, space, start, stop, step, slice_length, arr):
-i = start
 if not isinstance(arr, BaseArray):
 arr = convert_to_array(space, arr)
 if step > 0:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: make the test assert something

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45800:96cbeff5195d
Date: 2011-07-21 10:42 +0200
http://bitbucket.org/pypy/pypy/changeset/96cbeff5195d/

Log:make the test assert something

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
@@ -115,9 +115,9 @@
 assert a[4] == 11.
 a = zeros(10)
 a[::2][::-1][::2] = array(range(1,4))
-a[8] = 1.
-a[4] = 2.
-a[0] = 3.
+assert a[8] == 1.
+assert a[4] == 2.
+assert a[0] == 3.
 
 def test_setslice_list(self):
 from numpy import array
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests and improve signature

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45799:2c43451adecb
Date: 2011-07-21 10:41 +0200
http://bitbucket.org/pypy/pypy/changeset/2c43451adecb/

Log:fix tests and improve signature

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
@@ -444,12 +444,10 @@
 
 def _sliceloop1(self, start, stop, step, arr):
 storage = self.parent.storage
-signature = Signature()
-new_sig = self.signature.transition(signature)
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=signature, self=self,
+slice_driver1.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 storage[i] = arr.eval(j)
 j += 1
@@ -457,12 +455,10 @@
 
 def _sliceloop2(self, start, stop, step, arr):
 storage = self.parent.storage
-signature = Signature()
-new_sig = self.signature.transition(signature)
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=signature, self=self,
+slice_driver2.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 storage[i] = arr.eval(j)
 j += 1
@@ -516,7 +512,7 @@
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=self.signature, self=self,
+slice_driver1.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 self.storage[i] = arr.eval(j)
 j += 1
@@ -526,7 +522,7 @@
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=self.signature, self=self,
+slice_driver2.jit_merge_point(signature=arr.signature, self=self,
 step=step, stop=stop, i=i, j=j, arr=arr)
 self.storage[i] = arr.eval(j)
 j += 1
diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -49,8 +49,6 @@
 assert result == f(5)
 
 def test_neg(self):
-space = self.space
-
 def f(i):
 ar = SingleDimArray(i)
 v = Call1(neg, ar, Signature())
@@ -105,6 +103,7 @@
   "float_gt": 1, "int_add": 1,
   "int_lt": 1, "guard_true": 1, 
   "guard_false": 1, "jump": 1})
+assert result == f(5)
 
 def test_min(self):
 space = self.space
@@ -122,6 +121,7 @@
"float_lt": 1, "int_add": 1,
"int_lt": 1, "guard_true": 2,
"jump": 1})
+assert result == f(5)
 
 def test_argmin(self):
 space = self.space
@@ -139,6 +139,7 @@
"float_lt": 1, "int_add": 1,
"int_lt": 1, "guard_true": 2,
"jump": 1})
+assert result == f(5)
 
 def test_all(self):
 space = self.space
@@ -154,6 +155,7 @@
 self.check_loops({"getarrayitem_raw": 2, "float_add": 1,
   "int_add": 1, "float_ne": 1,
   "int_lt": 1, "guard_true": 2, "jump": 1})
+assert result == f(5)
 
 def test_any(self):
 space = self.space
@@ -166,6 +168,7 @@
 self.check_loops({"getarrayitem_raw": 2, "float_add": 1,
   "int_add": 1, "float_ne": 1, "guard_false": 1,
   "int_lt": 1, "guard_true": 1, "jump": 1})
+assert result == f(5)
 
 def test_already_forecd(self):
 def f(i):
@@ -257,7 +260,11 @@
 ar = SingleDimArray(step*i)
 ar2 = SingleDimArray(i)
 ar2.storage[1] = 5.5
-ar.setslice(space, 0, step*i, step, i, ar2.descr_add(space, ar2))
+if NonConstant(False):
+arg = ar2
+else:
+arg = ar2.descr_add(space, ar2)
+ar.setslice(space, 0, step*i, step, i, arg)
 return ar.get_concrete().storage[3]
 
 result = self.meta_interp(f, [5], listops=True, backendopt=True)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] jitviewer default: first go at working filter

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r152:3b5afee740b3
Date: 2011-07-21 11:43 +0200
http://bitbucket.org/pypy/jitviewer/changeset/3b5afee740b3/

Log:first go at working filter

diff --git a/_jitviewer/static/script.js b/_jitviewer/static/script.js
--- a/_jitviewer/static/script.js
+++ b/_jitviewer/static/script.js
@@ -38,7 +38,14 @@
 $("#inp-bar").focus();
 $("#inp-bar").bind("click keyup", function() {
 var value = $("#inp-bar")[0].value;
-
+$(".loopitem").each(function (i, l) {
+glob = l;
+if (l.getAttribute('name').search(value) != -1) {
+$(l).show();
+} else {
+$(l).hide();
+}
+});
 });
 }
 
diff --git a/_jitviewer/templates/index.html b/_jitviewer/templates/index.html
--- a/_jitviewer/templates/index.html
+++ b/_jitviewer/templates/index.html
@@ -29,9 +29,9 @@
 
   {% for is_entry_bridge, index, item in loops %}
   {% if is_entry_bridge %}
-Entry bridge: {{item.repr()}} run 
{{item.count}} times
+Entry bridge: {{item.repr()}} run 
{{item.count}} times
   {% else %}
-{{item.repr()}} run 
{{item.count}} times
+{{item.repr()}} run {{item.count}} times
   {% endif %}
   {% endfor %}
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-short_from_state: cleaner

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45801:d5c554280935
Date: 2011-07-20 16:48 +0200
http://bitbucket.org/pypy/pypy/changeset/d5c554280935/

Log:cleaner

diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py 
b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -289,21 +289,21 @@
 array  = self.getvalue(op.getarg(0))
 result = self.getvalue(op.result)
 array.make_len_gt(MODE_ARRAY, op.getdescr(), -1)
-result.intbound = array.lenbound[2]
+result.intbound = array.lenbound.bound
 
 def optimize_STRLEN(self, op):
 self.emit_operation(op)
 array  = self.getvalue(op.getarg(0))
 result = self.getvalue(op.result)
 array.make_len_gt(MODE_STR, op.getdescr(), -1)
-result.intbound = array.lenbound[2]
+result.intbound = array.lenbound.bound
 
 def optimize_UNICODELEN(self, op):
 self.emit_operation(op)
 array  = self.getvalue(op.getarg(0))
 result = self.getvalue(op.result)
 array.make_len_gt(MODE_UNICODE, op.getdescr(), -1)
-result.intbound = array.lenbound[2]
+result.intbound = array.lenbound.bound
 
 def optimize_STRGETITEM(self, op):
 self.emit_operation(op)
diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py 
b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -25,6 +25,11 @@
 MODE_ARRAY   = '\x00'
 MODE_STR = '\x01'
 MODE_UNICODE = '\x02'
+class LenBound(object):
+def __init__(self, mode, descr, bound):
+self.mode = mode
+self.descr = descr
+self.bound = bound
 
 class OptValue(object):
 __metaclass__ = extendabletype
@@ -55,11 +60,11 @@
 
 def make_len_gt(self, mode, descr, val):
 if self.lenbound:
-assert self.lenbound[0] == mode
-assert self.lenbound[1] == descr
-self.lenbound[2].make_gt(IntBound(val, val))
+assert self.lenbound.mode == mode
+assert self.lenbound.descr == descr
+self.lenbound.bound.make_gt(IntBound(val, val))
 else:
-self.lenbound = (mode, descr, IntLowerBound(val + 1))
+self.lenbound = LenBound(mode, descr, IntLowerBound(val + 1))
 
 def make_guards(self, box):
 guards = []
@@ -78,17 +83,17 @@
 self.intbound.make_guards(box, guards)
 if self.lenbound:
 lenbox = BoxInt()
-if self.lenbound[0] == MODE_ARRAY:
-op = ResOperation(rop.ARRAYLEN_GC, [box], lenbox, 
self.lenbound[1])
-elif self.lenbound[0] == MODE_STR:
-op = ResOperation(rop.STRLEN, [box], lenbox, 
self.lenbound[1])
-elif self.lenbound[0] == MODE_UNICODE:
-op = ResOperation(rop.UNICODELEN, [box], lenbox, 
self.lenbound[1])
+if self.lenbound.mode == MODE_ARRAY:
+op = ResOperation(rop.ARRAYLEN_GC, [box], lenbox, 
self.lenbound.descr)
+elif self.lenbound.mode == MODE_STR:
+op = ResOperation(rop.STRLEN, [box], lenbox, 
self.lenbound.descr)
+elif self.lenbound.mode == MODE_UNICODE:
+op = ResOperation(rop.UNICODELEN, [box], lenbox, 
self.lenbound.descr)
 else:
 debug_print("Unknown lenbound mode")
 assert False
 guards.append(op)
-self.lenbound[2].make_guards(lenbox, guards)
+self.lenbound.bound.make_guards(lenbox, guards)
 
 return guards
 
diff --git a/pypy/jit/metainterp/optimizeopt/virtualstate.py 
b/pypy/jit/metainterp/optimizeopt/virtualstate.py
--- a/pypy/jit/metainterp/optimizeopt/virtualstate.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualstate.py
@@ -237,9 +237,9 @@
 bad[other] = True
 return False
 if self.lenbound and other.lenbound:
-if self.lenbound[0] != other.lenbound[0] or \
-   self.lenbound[1] != other.lenbound[1] or \
-   not self.lenbound[2].contains_bound(other.lenbound[2]):
+if self.lenbound.mode != other.lenbound.mode or \
+   self.lenbound.descr != other.lenbound.descr or \
+   not self.lenbound.bound.contains_bound(other.lenbound.bound):
 bad[self] = True
 bad[other] = True
 return False
@@ -341,7 +341,7 @@
 
 lb = ''
 if self.lenbound:
-lb = ', ' + self.lenbound[2].__repr__()
+lb = ', ' + self.lenbound.bound.__repr__()
 
 debug_print(indent + mark + 'NotVirtualInfo(%d' % self.position +
 ', ' + l + ', ' + self.intbound.__repr__() + lb + ')')
__

[pypy-commit] pypy jit-short_from_state: dont lose intbound on lengths of virtuals

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45802:9b09294e5686
Date: 2011-07-21 12:14 +0200
http://bitbucket.org/pypy/pypy/changeset/9b09294e5686/

Log:dont lose intbound on lengths of virtuals

diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py 
b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -289,6 +289,7 @@
 array  = self.getvalue(op.getarg(0))
 result = self.getvalue(op.result)
 array.make_len_gt(MODE_ARRAY, op.getdescr(), -1)
+array.lenbound.bound.intersect(result.intbound)
 result.intbound = array.lenbound.bound
 
 def optimize_STRLEN(self, op):
@@ -296,6 +297,7 @@
 array  = self.getvalue(op.getarg(0))
 result = self.getvalue(op.result)
 array.make_len_gt(MODE_STR, op.getdescr(), -1)
+array.lenbound.bound.intersect(result.intbound)
 result.intbound = array.lenbound.bound
 
 def optimize_UNICODELEN(self, op):
@@ -303,6 +305,7 @@
 array  = self.getvalue(op.getarg(0))
 result = self.getvalue(op.result)
 array.make_len_gt(MODE_UNICODE, op.getdescr(), -1)
+array.lenbound.bound.intersect(result.intbound)
 result.intbound = array.lenbound.bound
 
 def optimize_STRGETITEM(self, op):
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -6687,7 +6687,43 @@
 """
 self.optimize_loop(ops, expected, expected_short=short)
 
-
+def test_propagate_virtual_arryalen(self):
+ops = """
+[p0]
+p404 = new_array(2, descr=arraydescr)
+p403 = new_array(3, descr=arraydescr)
+i405 = arraylen_gc(p404, descr=arraydescr)
+i406 = arraylen_gc(p403, descr=arraydescr)
+i407 = int_add_ovf(i405, i406)
+guard_no_overflow() []
+call(i407, descr=nonwritedescr)
+jump(p0)
+"""
+expected = """
+[p0]
+call(5, descr=nonwritedescr)
+jump(p0)
+"""
+self.optimize_loop(ops, expected)
+
+def test_propagate_virtual_strunicodelen(self):
+ops = """
+[p0]
+p404 = newstr(2)
+p403 = newunicode(3)
+i405 = strlen(p404)
+i406 = unicodelen(p403)
+i407 = int_add_ovf(i405, i406)
+guard_no_overflow() []
+call(i407, descr=nonwritedescr)
+jump(p0)
+"""
+expected = """
+[p0]
+call(5, descr=nonwritedescr)
+jump(p0)
+"""
+self.optimize_loop(ops, expected)
 
 class TestLLtype(OptimizeOptTest, LLtypeMixin):
 pass
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: write a test_pypy_c test

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45803:2171351a31a8
Date: 2011-07-21 11:29 +0200
http://bitbucket.org/pypy/pypy/changeset/2171351a31a8/

Log:write a test_pypy_c test

diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py 
b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -23,3 +23,29 @@
 ops = loop.ops_by_id('look')
 assert log.opnames(ops) == ['setfield_gc',
 'guard_not_invalidated']
+
+def test_identitydict(self):
+def fn(n):
+class X(object):
+pass
+x = X()
+d = {}
+d[x] = 1
+res = 0
+for i in range(300):
+value = d[x]  # ID: getitem
+res += value
+return res
+#
+log = self.run(fn, [1000])
+assert log.result == 300
+loop, = log.loops_by_filename(self.filepath)
+# check that the call to ll_dict_lookup is not a call_may_force
+assert loop.match_by_id("getitem", """
+i25 = call(ConstClass(_ll_1_gc_identityhash__objectPtr), p6, 
descr=...)
+...
+i28 = 
call(ConstClass(ll_dict_lookup__dicttablePtr_objectPtr_Signed), p18, p6, i25, 
descr=...)
+...
+p33 = call(ConstClass(ll_get_value__dicttablePtr_Signed), p18, 
i28, descr=...)
+...
+""")
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: a passing test

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45804:3fa4e79e2664
Date: 2011-07-21 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/3fa4e79e2664/

Log:a passing test

diff --git a/pypy/objspace/std/test/test_identitydict.py 
b/pypy/objspace/std/test/test_identitydict.py
--- a/pypy/objspace/std/test/test_identitydict.py
+++ b/pypy/objspace/std/test/test_identitydict.py
@@ -167,3 +167,23 @@
 d = {x: 1}
 assert self.uses_identity_strategy(d)
 assert list(iter(d)) == [x]
+
+def test_mutate_class_and_then_compare(self):
+class X(object):
+pass
+class Y(object):
+pass
+
+x = X()
+y = Y()
+d1 = {x: 1}
+d2 = {y: 1}
+assert self.uses_identity_strategy(d1)
+assert self.uses_identity_strategy(d2)
+#
+X.__hash__ = lambda self: hash(y)
+X.__eq__ = lambda self, other: True
+#
+assert d1 == d2
+assert self.uses_identity_strategy(d1)
+assert not self.uses_identity_strategy(d2)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: kill the global versioning logic, and add a big comment which explains why it's not needed

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45805:76c609d60ebd
Date: 2011-07-21 12:11 +0200
http://bitbucket.org/pypy/pypy/changeset/76c609d60ebd/

Log:kill the global versioning logic, and add a big comment which
explains why it's not needed

diff --git a/pypy/objspace/std/identitydict.py 
b/pypy/objspace/std/identitydict.py
--- a/pypy/objspace/std/identitydict.py
+++ b/pypy/objspace/std/identitydict.py
@@ -1,3 +1,6 @@
+## 
+## dict strategy (see dict_multiobject.py)
+
 from pypy.rlib import rerased
 from pypy.objspace.std.dictmultiobject import (AbstractTypedStrategy,
DictStrategy,
@@ -5,39 +8,6 @@
_UnwrappedIteratorMixin)
 
 
-# a global (per-space) version counter to track live instances which "compare
-# by identity" (i.e., whose __eq__, __cmp__ and __hash__ are the default
-# ones).  The idea is to track only classes for which we checked the
-# compares_by_identity() status at least once: we increment the version if its
-# status might change, e.g. because we set one of those attributes.  The
-# actual work is done by W_TypeObject.mutated() and objecttype:descr_setclass
-
-def bump_global_version(space):
-if space.config.objspace.std.withidentitydict:
-space.fromcache(ComparesByIdentityVersion).bump()
-
-def get_global_version(space):
-if space.config.objspace.std.withidentitydict:
-return space.fromcache(ComparesByIdentityVersion).get()
-return None
-
-class ComparesByIdentityVersion(object):
-
-def __init__(self, space):
-self.bump()
-
-def bump(self):
-from pypy.objspace.std.typeobject import VersionTag
-self._version = VersionTag()
-
-def get(self):
-return self._version
-
-
-
-## 
-## dict strategy (see dict_multiobject.py)
-
 # this strategy is selected by EmptyDictStrategy.switch_to_correct_strategy
 class IdentityDictStrategy(AbstractTypedStrategy, DictStrategy):
 """
@@ -45,11 +15,48 @@
 default unless you override __hash__, __eq__ or __cmp__).  The storage is
 just a normal RPython dict, which has already the correct by-identity
 semantics.
+
+Note that at a first sight, you might have problems if you mutate the
+class of an object which is already inside an identitydict.  Consider this
+example::
+
+class X(object):
+pass
+d = {x(): 1}
+X.__eq__ = ...
+d[y] # might trigger a call to __eq__?
+
+We want to be sure that x.__eq__ is called in the same cases as in
+CPython.  However, as long as the strategy is IdentityDictStrategy, the
+__eq__ will never be called.
+
+It turns out that it's not a problem.  In CPython (and in PyPy without
+this strategy), the __eq__ is called if ``hash(y) == hash(x)`` and ``x is
+not y``.  Note that hash(x) is computed at the time when we insert x in
+the dict, not at the time we lookup y.
+
+Now, how can hash(y) == hash(x)?  There are two possibilities:
+
+  1. we write a custom __hash__ for the class of y, thus making it a not
+"compares by reference" type
+
+  2. the class of y is "compares by reference" type, and by chance the
+ hash is the same as x
+
+In the first case, the getitem immediately notice that y is not of the
+right type, and switches the strategy to ObjectDictStrategy, then the
+lookup works as usual.
+
+The second case is completely non-deterministic, even in CPython.
+Depending on the phase of the moon, you might call the __eq__ or not, so
+it is perfectly fine to *never* call it.  Morever, in practice with the
+minimar GC we never have two live objects with the same hash, so it would
+never happen anyway.
 """
 
-_erase_tuple, _unerase_tuple = rerased.new_erasing_pair("identitydict")
-_erase_tuple = staticmethod(_erase_tuple)
-_unerase_tuple = staticmethod(_unerase_tuple)
+erase, unerase = rerased.new_erasing_pair("identitydict")
+erase = staticmethod(erase)
+unerase = staticmethod(unerase)
 
 def wrap(self, unwrapped):
 return unwrapped
@@ -57,18 +64,6 @@
 def unwrap(self, wrapped):
 return wrapped
 
-def erase(self, d):
-current_version = get_global_version(self.space)
-return self._erase_tuple((current_version, d))
-
-def unerase(self, dstorage):
-version, d = self._unerase_tuple(dstorage)
-return d
-
-def get_current_version(self, dstorage):
-version, d = self._unerase_tuple(dstorage)
-return version
-
 def get_empty_storage(self):
 return self.erase({})
 
diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -43,9 +43,6 @@
 

[pypy-commit] pypy identity-dict-strategy: add a test for old classes, which are not supported

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45806:d8d5656b9fb0
Date: 2011-07-21 13:40 +0200
http://bitbucket.org/pypy/pypy/changeset/d8d5656b9fb0/

Log:add a test for old classes, which are not supported

diff --git a/pypy/objspace/std/test/test_identitydict.py 
b/pypy/objspace/std/test/test_identitydict.py
--- a/pypy/objspace/std/test/test_identitydict.py
+++ b/pypy/objspace/std/test/test_identitydict.py
@@ -45,7 +45,6 @@
 assert self.compares_by_identity(X)
 
 
-
 class AppTestIdentityDict(object):
 def setup_class(cls):
 cls.space = gettestobjspace(**{"objspace.std.withidentitydict": True})
@@ -128,3 +127,10 @@
 assert d1 == d2
 assert self.uses_identity_strategy(d1)
 assert not self.uses_identity_strategy(d2)
+
+def test_old_style_classes(self):
+class X:
+pass
+
+d = {X(): 1}
+assert not self.uses_identity_strategy(d)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: kill empty line

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45807:23f86e47c147
Date: 2011-07-21 13:48 +0200
http://bitbucket.org/pypy/pypy/changeset/23f86e47c147/

Log:kill empty line

diff --git a/pypy/objspace/std/test/test_identitydict.py 
b/pypy/objspace/std/test/test_identitydict.py
--- a/pypy/objspace/std/test/test_identitydict.py
+++ b/pypy/objspace/std/test/test_identitydict.py
@@ -131,6 +131,5 @@
 def test_old_style_classes(self):
 class X:
 pass
-
 d = {X(): 1}
 assert not self.uses_identity_strategy(d)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: update to new interp interface and bench for PyROOT

2011-07-21 Thread wlav
Author: Wim Lavrijsen 
Branch: reflex-support
Changeset: r45809:dbf532b2eb5c
Date: 2011-07-19 06:50 -0700
http://bitbucket.org/pypy/pypy/changeset/dbf532b2eb5c/

Log:update to new interp interface and bench for PyROOT

diff --git a/pypy/module/cppyy/test/bench1.py b/pypy/module/cppyy/test/bench1.py
--- a/pypy/module/cppyy/test/bench1.py
+++ b/pypy/module/cppyy/test/bench1.py
@@ -15,7 +15,7 @@
 
 def print_bench(name, t_bench):
 global t_cppref
-print ' %s cost: %#6.3fs (%#4dx)' % (name, t_bench, t_bench/t_cppref)
+print ' %s cost: %#6.3fs (%#4.1fx)' % (name, t_bench, 
float(t_bench)/t_cppref)
 
 def python_loop_offset():
 for i in range(NNN):
@@ -40,6 +40,14 @@
 instance.addDataToInt(i)
 return i
 
+class PyROOTBench1(PyCintexBench1):
+def __init__(self):
+import ROOT
+self.lib = ROOT.gSystem.Load("./example01Dict_cint.so")
+
+self.cls   = ROOT.example01
+self.inst  = self.cls(0)
+
 class CppyyInterpBench1(object):
 scale = 1
 def __init__(self):
@@ -47,15 +55,13 @@
 self.lib = cppyy.load_lib("./example01Dict.so")
 
 self.cls  = cppyy._type_byname("example01")
-self.inst = self.cls.construct(0)
+self.inst = self.cls.get_overload(self.cls.type_name).call(None, 
cppyy.CPPInstance, 0)
 
 def __call__(self):
 addDataToInt = self.cls.get_overload("addDataToInt")
 instance = self.inst
 for i in range(NNN):
-#inst.invoke(cls.get_overload("addDataToDouble"), float(i))
-#inst.invoke(cls.get_overload("addDataToInt"), i)
-instance.invoke(addDataToInt, i)
+addDataToInt.call(instance, None, i)
 return i
 
 class CppyyPythonBench1(object):
@@ -89,6 +95,12 @@
 print run_bench(cintex_bench1)
 sys.exit(0)
 
+# special case for PyCintex (run under python, not pypy-c)
+if '--pyroot' in sys.argv:
+pyroot_bench1 = PyROOTBench1()
+print run_bench(pyroot_bench1)
+sys.exit(0)
+
 # get C++ reference point
 if not os.path.exists("bench1.exe") or\
 os.stat("bench1.exe").st_mtime < os.stat("bench1.cxx").st_mtime:
@@ -111,3 +123,5 @@
 print_bench("cppyy python", run_bench(python_bench1))
 stat, t_cintex = commands.getstatusoutput("python bench1.py --pycintex")
 print_bench("pycintex", float(t_cintex))
+#stat, t_pyroot = commands.getstatusoutput("python bench1.py --pyroot")
+#print_bench("pyroot  ", float(t_pyroot))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: rules for compiling .cxx in generated makefile

2011-07-21 Thread wlav
Author: Wim Lavrijsen 
Branch: reflex-support
Changeset: r45810:f93d9c300124
Date: 2011-07-21 05:04 -0700
http://bitbucket.org/pypy/pypy/changeset/f93d9c300124/

Log:rules for compiling .cxx in generated makefile

diff --git a/pypy/translator/platform/posix.py 
b/pypy/translator/platform/posix.py
--- a/pypy/translator/platform/posix.py
+++ b/pypy/translator/platform/posix.py
@@ -125,7 +125,7 @@
 return fpath
 
 rel_cfiles = [m.pathrel(cfile) for cfile in cfiles]
-rel_ofiles = [rel_cfile[:-2]+'.o' for rel_cfile in rel_cfiles]
+rel_ofiles = [rel_cfile[:rel_cfile.rfind('.')]+'.o' for rel_cfile in 
rel_cfiles]
 m.cfiles = rel_cfiles
 
 rel_includedirs = [pypyrel(incldir) for incldir in
@@ -159,6 +159,7 @@
 ('all', '$(DEFAULT_TARGET)', []),
 ('$(TARGET)', '$(OBJECTS)', '$(CC_LINK) $(LDFLAGS) $(LDFLAGSEXTRA) 
-o $@ $(OBJECTS) $(LIBDIRS) $(LIBS) $(LINKFILES)'),
 ('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< 
$(INCLUDEDIRS)'),
+('%.o', '%.cxx', '$(CXX) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< 
$(INCLUDEDIRS)'),
 ]
 
 for rule in rules:
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: merge heads

2011-07-21 Thread wlav
Author: Wim Lavrijsen 
Branch: reflex-support
Changeset: r45811:bddd0178cf08
Date: 2011-07-21 05:05 -0700
http://bitbucket.org/pypy/pypy/changeset/bddd0178cf08/

Log:merge heads

diff --git a/pypy/module/cppyy/test/bench1.py b/pypy/module/cppyy/test/bench1.py
--- a/pypy/module/cppyy/test/bench1.py
+++ b/pypy/module/cppyy/test/bench1.py
@@ -15,7 +15,7 @@
 
 def print_bench(name, t_bench):
 global t_cppref
-print ' %s cost: %#6.3fs (%#4dx)' % (name, t_bench, t_bench/t_cppref)
+print ' %s cost: %#6.3fs (%#4.1fx)' % (name, t_bench, 
float(t_bench)/t_cppref)
 
 def python_loop_offset():
 for i in range(NNN):
@@ -40,6 +40,14 @@
 instance.addDataToInt(i)
 return i
 
+class PyROOTBench1(PyCintexBench1):
+def __init__(self):
+import ROOT
+self.lib = ROOT.gSystem.Load("./example01Dict_cint.so")
+
+self.cls   = ROOT.example01
+self.inst  = self.cls(0)
+
 class CppyyInterpBench1(object):
 scale = 1
 def __init__(self):
@@ -47,15 +55,13 @@
 self.lib = cppyy.load_lib("./example01Dict.so")
 
 self.cls  = cppyy._type_byname("example01")
-self.inst = self.cls.construct(0)
+self.inst = self.cls.get_overload(self.cls.type_name).call(None, 
cppyy.CPPInstance, 0)
 
 def __call__(self):
 addDataToInt = self.cls.get_overload("addDataToInt")
 instance = self.inst
 for i in range(NNN):
-#inst.invoke(cls.get_overload("addDataToDouble"), float(i))
-#inst.invoke(cls.get_overload("addDataToInt"), i)
-instance.invoke(addDataToInt, i)
+addDataToInt.call(instance, None, i)
 return i
 
 class CppyyPythonBench1(object):
@@ -89,6 +95,12 @@
 print run_bench(cintex_bench1)
 sys.exit(0)
 
+# special case for PyCintex (run under python, not pypy-c)
+if '--pyroot' in sys.argv:
+pyroot_bench1 = PyROOTBench1()
+print run_bench(pyroot_bench1)
+sys.exit(0)
+
 # get C++ reference point
 if not os.path.exists("bench1.exe") or\
 os.stat("bench1.exe").st_mtime < os.stat("bench1.cxx").st_mtime:
@@ -111,3 +123,5 @@
 print_bench("cppyy python", run_bench(python_bench1))
 stat, t_cintex = commands.getstatusoutput("python bench1.py --pycintex")
 print_bench("pycintex", float(t_cintex))
+#stat, t_pyroot = commands.getstatusoutput("python bench1.py --pyroot")
+#print_bench("pyroot  ", float(t_pyroot))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: document this small difference

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45812:a02a3e34b4f2
Date: 2011-07-21 14:07 +0200
http://bitbucket.org/pypy/pypy/changeset/a02a3e34b4f2/

Log:document this small difference

diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -211,6 +211,38 @@
  print d1['a']
 42
 
+Mutating classes of objects which are already used as dictionary keys
+-
+
+Consider the following snippet of code::
+
+class X(object):
+pass
+
+def __evil_eq__(self, other):
+print 'hello world'
+return False
+
+def evil(y):
+d = {x(): 1}
+X.__eq__ = __evil_eq__
+d[y] # might trigger a call to __eq__?
+
+In CPython, __evil_eq__ **might** be called, although there is no way to write
+a test which reliably calls it.  It happens if ``y is not x`` and ``hash(y) ==
+hash(x)``, where ``hash(x)`` is computed when ``x`` is inserted into the
+dictionary.  If **by chance** the condition is satisfied, then ``__evil_eq__``
+is called.
+
+PyPy uses a special strategy to optimize dictionaries whose keys are instances
+of user-defined classes which do not override the default ``__hash__``,
+``__eq__`` and ``__cmp__``: when using this strategy, ``__eq__`` and
+``__cmp__`` are never called, but instead the lookup is done by identity, so
+in the case above it is guaranteed that ``__eq__`` won't be called.
+
+Note that in all other cases (e.g., if you have a custom ``__hash__`` and
+``__eq__`` in ``y``) the behavior is exactly the same as CPython.
+
 
 Ignored exceptions
 ---
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: bench02 code cleanup and test of bench

2011-07-21 Thread wlav
Author: Wim Lavrijsen 
Branch: reflex-support
Changeset: r45813:41aebf1d8db1
Date: 2011-07-21 05:15 -0700
http://bitbucket.org/pypy/pypy/changeset/41aebf1d8db1/

Log:bench02 code cleanup and test of bench

diff --git a/pypy/module/cppyy/bench/bench02.cxx 
b/pypy/module/cppyy/bench/bench02.cxx
--- a/pypy/module/cppyy/bench/bench02.cxx
+++ b/pypy/module/cppyy/bench/bench02.cxx
@@ -1,4 +1,5 @@
 #include "bench02.h"
+
 #include "TROOT.h"
 #include "TApplication.h"
 #include "TDirectory.h"
@@ -10,92 +11,64 @@
 #include "Getline.h"
 #include "TVirtualX.h"
 
-// CINT
 #include "Api.h"
 
 #include 
 
+
 class TTestApplication : public TApplication {
 public:
TTestApplication(
-  const char* acn, Int_t* argc, char** argv, Bool_t bLoadLibs = kTRUE );
-
+const char* acn, Int_t* argc, char** argv, Bool_t bLoadLibs = kTRUE);
virtual ~TTestApplication();
 };
 
-
-//- constructors/destructor --
 TTestApplication::TTestApplication(
-   const char* acn, int* argc, char** argv, bool bLoadLibs ) :
-  TApplication( acn, argc, argv )
-{
-// Create a TApplication derived for use with interactive ROOT from python. A
-// set of standard, often used libs is loaded if bLoadLibs is true (default).
-
-   if ( bLoadLibs )   // note that this section could be programmed in python
-   {
+const char* acn, int* argc, char** argv, bool do_load) : 
TApplication(acn, argc, argv) {
+if (do_load) {
// follow TRint to minimize differences with CINT
-  ProcessLine( "#include ", kTRUE );
-  ProcessLine( "#include <_string>",  kTRUE ); // for std::string iostream.
-  ProcessLine( "#include ",   kTRUE ); // needed because they're 
used within the
-  ProcessLine( "#include ", kTRUE ); //  core ROOT dicts and 
CINT won't be able
+ProcessLine("#include ", kTRUE);
+ProcessLine("#include <_string>",  kTRUE); // for std::string iostream.
+ProcessLine("#include ",   kTRUE); // needed because they're 
used within the
+ProcessLine("#include ", kTRUE); //  core ROOT dicts and 
CINT won't be able
//  to properly unload 
these files
-
-   // following RINT, these are now commented out (rely on auto-loading)
-   //   // the following libs are also useful to have, make sure they are 
loaded...
-   //  gROOT->LoadClass("TMinuit", "Minuit");
-   //  gROOT->LoadClass("TPostScript", "Postscript");
-   //  gROOT->LoadClass("THtml",   "Html");
}
 
-#ifdef WIN32
-   // switch win32 proxy main thread id
-   if (gVirtualX)
-  ProcessLine("((TGWin32 *)gVirtualX)->SetUserThreadId(0);", kTRUE);
-#endif
-
-// save current interpreter context
+// save current interpreter context
gInterpreter->SaveContext();
gInterpreter->SaveGlobalsContext();
 
-// prevent crashes on accessing histor
-   Gl_histinit( (char*)"-" );
+// prevent crashes on accessing history
+Gl_histinit((char*)"-");
 
-// prevent ROOT from exiting python
-   SetReturnFromRun( kTRUE );
+// prevent ROOT from exiting python
+SetReturnFromRun(kTRUE);
 }
 
 TTestApplication::~TTestApplication() {}
 
 static const char* appname = "pypy-cppyy";
 
-CloserHack::CloserHack() {
-   std::cout << "gROOT is: " << gROOT << std::endl;
-   std::cout << "gApplication is: " << gApplication << std::endl;
-
-   if ( ! gApplication ) {
-   // retrieve arg list from python, translate to raw C, pass on
+Bench02RootApp::Bench02RootApp() {
+if (!gApplication) {
   int argc = 1;
   char* argv[1]; argv[0] = (char*)appname;
-  gApplication = new TTestApplication( appname, &argc, argv, kTRUE );
+gApplication = new TTestApplication(appname, &argc, argv, kTRUE);
}
-
-   std::cout << "gApplication is: " << gApplication << std::endl;
 }
 
-void CloserHack::report() {
+Bench02RootApp::~Bench02RootApp() {
+// TODO: ROOT globals cleanup ... (?)
+}
+
+void Bench02RootApp::report() {
std::cout << "gROOT is: " << gROOT << std::endl;
std::cout << "gApplication is: " << gApplication << std::endl;
 }
 
-void CloserHack::close() {
-   std::cout << "closing file ... " << std::endl;
-   if (gDirectory && gDirectory != gROOT) {
-   gDirectory->Write();
-   gDirectory->Close();
-   }
+void Bench02RootApp::close_file(TFile* f) {
+std::cout << "closing file " << f->GetName() << " ... " << std::endl;
+f->Write();
+f->Close();
+std::cout << "... file closed" << std::endl;
 }
-
-CloserHack::~CloserHack() {
-}
-
diff --git a/pypy/module/cppyy/bench/bench02.h 
b/pypy/module/cppyy/bench/bench02.h
--- a/pypy/module/cppyy/bench/bench02.h
+++ b/pypy/module/cppyy/bench/bench02.h
@@ -4,18 +4,45 @@
 #include "TNtuple.h"
 #include "TH1F.h"
 #include "TH2F.h"
+#include "TRandom.h"
 
 #include "TROOT.h"
 #include "TApplication.h"
 
+#include "TBox.h"
+#include "TClassGenerator.h"
+#include "TF1.h"
+#include "TFileMergeInfo.h"
+#include "TFolder.h"
+#include "TFu

[pypy-commit] pypy reflex-support: improved error reporting for unknown typed data members

2011-07-21 Thread wlav
Author: Wim Lavrijsen 
Branch: reflex-support
Changeset: r45814:d099ce6f
Date: 2011-07-21 05:15 -0700
http://bitbucket.org/pypy/pypy/changeset/d099ce6f/

Log:improved error reporting for unknown typed data members

diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -43,22 +43,22 @@
 fieldptr = rffi.cast(rffi.CCHARP, offset)
 return fieldptr
 
-def _is_abstract(self):
-raise NotImplementedError(
-"abstract base class" ) # more detailed part is not rpython: 
(actual: %s)" % type(self).__name__)
+def _is_abstract(self, space):
+raise OperationError(space.w_NotImplementedError,
+ space.wrap("no converter available")) # more 
detailed part is not rpython: (actual: %s)" % type(self).__name__))
 
 def convert_argument(self, space, w_obj, address):
-self._is_abstract()
+self._is_abstract(space)
 
 def convert_argument_libffi(self, space, w_obj, argchain):
 from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
 raise FastCallNotPossible
 
 def from_memory(self, space, w_obj, w_type, offset):
-self._is_abstract()
+self._is_abstract(space)
 
 def to_memory(self, space, w_obj, w_value, offset):
-self._is_abstract()
+self._is_abstract(space)
 
 def free_argument(self, arg):
 pass
diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -74,7 +74,13 @@
 if not rettype:  # return builtin type
 cppclass = None
 else:# return instance
+try:
 cppclass = get_cppclass(rettype)
+except AttributeError, e:
+import warnings
+warnings.warn("class %s unknown: no data member access" % rettype,
+  RuntimeWarning)
+cppclass = None
 if cppdm.is_static():
 def binder(obj):
 return cppdm.get(None, cppclass)
diff --git a/pypy/module/cppyy/test/fragile.h b/pypy/module/cppyy/test/fragile.h
--- a/pypy/module/cppyy/test/fragile.h
+++ b/pypy/module/cppyy/test/fragile.h
@@ -28,4 +28,15 @@
 void overload(int, no_such_class* p = 0) {}
 };
 
+class E {
+public:
+E() : m_pp_no_such(0), m_pp_a(0) {}
+
+virtual int check() { return (int)'E'; }
+void overload(no_such_class**) {}
+
+no_such_class** m_pp_no_such;
+A** m_pp_a;
+};
+
 } // namespace fragile
diff --git a/pypy/module/cppyy/test/fragile.xml 
b/pypy/module/cppyy/test/fragile.xml
--- a/pypy/module/cppyy/test/fragile.xml
+++ b/pypy/module/cppyy/test/fragile.xml
@@ -2,9 +2,6 @@
 
   
 
-  
-  
-  
-  
+  
 
 
diff --git a/pypy/module/cppyy/test/test_fragile.py 
b/pypy/module/cppyy/test/test_fragile.py
--- a/pypy/module/cppyy/test/test_fragile.py
+++ b/pypy/module/cppyy/test/test_fragile.py
@@ -14,7 +14,7 @@
 if err:
 raise OSError("'make' failed (see stderr)")
 
-class AppTestSTL:
+class AppTestFRAGILE:
 def setup_class(cls):
 cls.space = space
 env = os.environ
@@ -65,3 +65,24 @@
 
 d = fragile.D()
 raises(TypeError, d.overload, None)
+raises(TypeError, d.overload, None, None, None)
+
+# TODO: the following fails in the fast path, b/c the default
+# arguments are not properly filled
+#d.overload('a')
+#d.overload(1)
+
+def test04_unsupported_arguments(self):
+"""Test arguments that are yet unsupported"""
+
+import cppyy
+
+assert cppyy.gbl.fragile == cppyy.gbl.fragile
+fragile = cppyy.gbl.fragile
+
+assert fragile.E == fragile.E
+assert fragile.E().check() == ord('E')
+
+e = fragile.E()
+raises(TypeError, e.overload, None)
+raises(NotImplementedError, getattr, e, 'm_pp_no_such')
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: write doc for this option

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45815:9c9eaa7e08db
Date: 2011-07-21 15:09 +0200
http://bitbucket.org/pypy/pypy/changeset/9c9eaa7e08db/

Log:write doc for this option

diff --git a/pypy/doc/config/objspace.std.withidentitydict.txt 
b/pypy/doc/config/objspace.std.withidentitydict.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/config/objspace.std.withidentitydict.txt
@@ -0,0 +1,21 @@
+=
+objspace.std.withidentitydict
+=
+
+* **name:** withidentitydict
+
+* **description:** enable a dictionary strategy for "by identity" comparisons
+
+* **command-line:** --objspace-std-withidentitydict
+
+* **command-line for negation:** --no-objspace-std-withidentitydict
+
+* **option type:** boolean option
+
+* **default:** True
+
+
+Enable a dictionary strategy specialized for instances of classes which
+compares "by identity", which is the default unless you override ``__hash__``,
+``__eq__`` or ``__cmp__``.  This strategy will be used only with new-style
+classes.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy identity-dict-strategy: close about-to-be-merged branch

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: identity-dict-strategy
Changeset: r45816:6746c1579cab
Date: 2011-07-21 15:10 +0200
http://bitbucket.org/pypy/pypy/changeset/6746c1579cab/

Log:close about-to-be-merged branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge the identity-dict-strategy branch, which optimizes access to dictionary containing only classes which compare 'by identity'

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r45817:69a7e76a319a
Date: 2011-07-21 15:10 +0200
http://bitbucket.org/pypy/pypy/changeset/69a7e76a319a/

Log:merge the identity-dict-strategy branch, which optimizes access to
dictionary containing only classes which compare 'by identity'

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -327,6 +327,9 @@
 BoolOption("mutable_builtintypes",
"Allow the changing of builtin types", default=False,
requires=[("objspace.std.builtinshortcut", True)]),
+BoolOption("withidentitydict",
+   "track types that override __hash__, __eq__ or __cmp__ and 
use a special dict strategy for those which do not",
+   default=True),
  ]),
 ])
 
diff --git a/pypy/doc/config/objspace.std.withidentitydict.txt 
b/pypy/doc/config/objspace.std.withidentitydict.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/config/objspace.std.withidentitydict.txt
@@ -0,0 +1,21 @@
+=
+objspace.std.withidentitydict
+=
+
+* **name:** withidentitydict
+
+* **description:** enable a dictionary strategy for "by identity" comparisons
+
+* **command-line:** --objspace-std-withidentitydict
+
+* **command-line for negation:** --no-objspace-std-withidentitydict
+
+* **option type:** boolean option
+
+* **default:** True
+
+
+Enable a dictionary strategy specialized for instances of classes which
+compares "by identity", which is the default unless you override ``__hash__``,
+``__eq__`` or ``__cmp__``.  This strategy will be used only with new-style
+classes.
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -211,6 +211,38 @@
  print d1['a']
 42
 
+Mutating classes of objects which are already used as dictionary keys
+-
+
+Consider the following snippet of code::
+
+class X(object):
+pass
+
+def __evil_eq__(self, other):
+print 'hello world'
+return False
+
+def evil(y):
+d = {x(): 1}
+X.__eq__ = __evil_eq__
+d[y] # might trigger a call to __eq__?
+
+In CPython, __evil_eq__ **might** be called, although there is no way to write
+a test which reliably calls it.  It happens if ``y is not x`` and ``hash(y) ==
+hash(x)``, where ``hash(x)`` is computed when ``x`` is inserted into the
+dictionary.  If **by chance** the condition is satisfied, then ``__evil_eq__``
+is called.
+
+PyPy uses a special strategy to optimize dictionaries whose keys are instances
+of user-defined classes which do not override the default ``__hash__``,
+``__eq__`` and ``__cmp__``: when using this strategy, ``__eq__`` and
+``__cmp__`` are never called, but instead the lookup is done by identity, so
+in the case above it is guaranteed that ``__eq__`` won't be called.
+
+Note that in all other cases (e.g., if you have a custom ``__hash__`` and
+``__eq__`` in ``y``) the behavior is exactly the same as CPython.
+
 
 Ignored exceptions
 ---
diff --git a/pypy/module/pypyjit/test_pypy_c/test_containers.py 
b/pypy/module/pypyjit/test_pypy_c/test_containers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_containers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_containers.py
@@ -23,3 +23,29 @@
 ops = loop.ops_by_id('look')
 assert log.opnames(ops) == ['setfield_gc',
 'guard_not_invalidated']
+
+def test_identitydict(self):
+def fn(n):
+class X(object):
+pass
+x = X()
+d = {}
+d[x] = 1
+res = 0
+for i in range(300):
+value = d[x]  # ID: getitem
+res += value
+return res
+#
+log = self.run(fn, [1000])
+assert log.result == 300
+loop, = log.loops_by_filename(self.filepath)
+# check that the call to ll_dict_lookup is not a call_may_force
+assert loop.match_by_id("getitem", """
+i25 = call(ConstClass(_ll_1_gc_identityhash__objectPtr), p6, 
descr=...)
+...
+i28 = 
call(ConstClass(ll_dict_lookup__dicttablePtr_objectPtr_Signed), p18, p6, i25, 
descr=...)
+...
+p33 = call(ConstClass(ll_get_value__dicttablePtr_Signed), p18, 
i28, descr=...)
+...
+""")
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -28,6 +28,13 @@
 return w_delattr
 object_delattr._annspecialcase_ = 'specialize:memo'
 
+def object_hash(space):
+"Utility that returns the app-level descriptor object.__hash__."
+w_src, w_hash = space.lookup_in_type_where(space.w_

[pypy-commit] pypy default: write doc for this option

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r45818:5f668bf0e242
Date: 2011-07-21 15:15 +0200
http://bitbucket.org/pypy/pypy/changeset/5f668bf0e242/

Log:write doc for this option

diff --git a/pypy/doc/config/translation.dont_write_c_files.txt 
b/pypy/doc/config/translation.dont_write_c_files.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/config/translation.dont_write_c_files.txt
@@ -0,0 +1,4 @@
+write the generated C files to ``/dev/null`` instead of to the disk. Useful if
+you want to use translate.py as a benchmark and don't want to access the disk.
+
+.. _`translation documentation`: ../translation.html
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: remove code duplication and fix the translation hopefully

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45819:aa1f3c5c459c
Date: 2011-07-21 15:57 +0200
http://bitbucket.org/pypy/pypy/changeset/aa1f3c5c459c/

Log:remove code duplication and fix the translation hopefully

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
@@ -25,8 +25,8 @@
  reds = ['result_size', 'i', 'self', 'result'])
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
-slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
-slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'self', 'arr'])
+slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
+slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
 
 def pos(v):
 return v
@@ -268,6 +268,26 @@
 def descr_mean(self, space):
 return 
space.wrap(space.float_w(self.descr_sum(space))/self.find_size())
 
+def _sliceloop1(self, start, stop, step, arr, storage):
+i = start
+j = 0
+while i < stop:
+slice_driver1.jit_merge_point(signature=arr.signature,
+step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+storage[i] = arr.eval(j)
+j += 1
+i += step
+
+def _sliceloop2(self, start, stop, step, arr, storage):
+i = start
+j = 0
+while i > stop:
+slice_driver2.jit_merge_point(signature=arr.signature,
+step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+storage[i] = arr.eval(j)
+j += 1
+i += step
+
 def convert_to_array (space, w_obj):
 if isinstance(w_obj, BaseArray):
 return w_obj
@@ -442,28 +462,6 @@
 def find_size(self):
 return self.size
 
-def _sliceloop1(self, start, stop, step, arr):
-storage = self.parent.storage
-i = start
-j = 0
-while i < stop:
-slice_driver1.jit_merge_point(signature=arr.signature, self=self,
-step=step, stop=stop, i=i, j=j, arr=arr)
-storage[i] = arr.eval(j)
-j += 1
-i += step
-
-def _sliceloop2(self, start, stop, step, arr):
-storage = self.parent.storage
-i = start
-j = 0
-while i > stop:
-slice_driver2.jit_merge_point(signature=arr.signature, self=self,
-step=step, stop=stop, i=i, j=j, arr=arr)
-storage[i] = arr.eval(j)
-j += 1
-i += step
-
 def setslice(self, space, start, stop, step, slice_length, arr):
 arr = convert_to_array(space, arr)
 start = self.calc_index(start)
@@ -471,9 +469,9 @@
 stop = self.calc_index(stop)
 step = self.step * step
 if step > 0:
-self._sliceloop1(start, stop, step, arr)
+self._sliceloop1(start, stop, step, arr, self.parent.storage)
 else:
-self._sliceloop2(start, stop, step, arr)
+self._sliceloop2(start, stop, step, arr, self.parent.storage)
 
 def calc_index(self, item):
 return (self.start + item * self.step)
@@ -508,33 +506,13 @@
 self.invalidated()
 self.storage[item] = value
 
-def _sliceloop1(self, start, stop, step, arr):
-i = start
-j = 0
-while i < stop:
-slice_driver1.jit_merge_point(signature=arr.signature, self=self,
-step=step, stop=stop, i=i, j=j, arr=arr)
-self.storage[i] = arr.eval(j)
-j += 1
-i += step
-
-def _sliceloop2(self, start, stop, step, arr):
-i = start
-j = 0
-while i > stop:
-slice_driver2.jit_merge_point(signature=arr.signature, self=self,
-step=step, stop=stop, i=i, j=j, arr=arr)
-self.storage[i] = arr.eval(j)
-j += 1
-i += step
-
 def setslice(self, space, start, stop, step, slice_length, arr):
 if not isinstance(arr, BaseArray):
 arr = convert_to_array(space, arr)
 if step > 0:
-self._sliceloop1(start, stop, step, arr)
+self._sliceloop1(start, stop, step, arr, self.storage)
 else:
-self._sliceloop2(start, stop, step, arr)
+self._sliceloop2(start, stop, step, arr, self.storage)
 
 def __del__(self):
 lltype.free(self.storage, flavor='raw')
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: translation fix

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r45820:abaf35bf5217
Date: 2011-07-21 16:11 +0200
http://bitbucket.org/pypy/pypy/changeset/abaf35bf5217/

Log:translation fix

diff --git a/pypy/objspace/std/dictproxyobject.py 
b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -86,7 +86,7 @@
 
 def clear(self, w_dict):
 self.unerase(w_dict.dstorage).dict_w.clear()
-self.unerase(w_dict.dstorage).mutated(None)
+self.unerase(w_dict.dstorage).mutated()
 
 class DictProxyIteratorImplementation(IteratorImplementation):
 def __init__(self, space, strategy, dictimplementation):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: this field is now quasi-immutable

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r45821:3e31e1098d65
Date: 2011-07-21 16:12 +0200
http://bitbucket.org/pypy/pypy/changeset/3e31e1098d65/

Log:this field is now quasi-immutable

diff --git a/pypy/module/pypyjit/test_pypy_c/test__ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test__ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test__ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test__ffi.py
@@ -30,7 +30,6 @@
 assert res == 8.0 * 300
 loop, = log.loops_by_filename(self.filepath)
 assert loop.match_by_id('fficall', """
-p16 = getfield_gc(ConstPtr(ptr15), descr=<.* .*Function.inst_name 
.*>)
 guard_not_invalidated(descr=...)
 i17 = force_token()
 setfield_gc(p0, i17, descr=<.* .*PyFrame.vable_token .*>)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy custom-trace: A branch in which to implement custom "tracers" for the GC.

2011-07-21 Thread arigo
Author: Armin Rigo 
Branch: custom-trace
Changeset: r45822:6e4633e7cfeb
Date: 2011-07-21 15:56 +0200
http://bitbucket.org/pypy/pypy/changeset/6e4633e7cfeb/

Log:A branch in which to implement custom "tracers" for the GC.

The goal is to let some special object types have a custom trace()
function.

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Easter-egg-like implementation of __pypy__.do_what_I_mean().

2011-07-21 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r45823:96b67e33eb50
Date: 2011-07-21 16:18 +0200
http://bitbucket.org/pypy/pypy/changeset/96b67e33eb50/

Log:Easter-egg-like implementation of __pypy__.do_what_I_mean().

diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -25,6 +25,7 @@
 'debug_print_once'  : 'interp_debug.debug_print_once',
 'builtinify': 'interp_magic.builtinify',
 'lookup_special': 'interp_magic.lookup_special',
+'do_what_I_mean': 'interp_magic.do_what_I_mean',
 }
 
 submodules = {
diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -70,3 +70,6 @@
 if w_descr is None:
 return space.w_None
 return space.get(w_descr, w_obj)
+
+def do_what_I_mean(space):
+return space.wrap(42)
diff --git a/pypy/module/__pypy__/test/test_special.py 
b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -49,3 +49,8 @@
 class X:
 pass
 raises(TypeError, lookup_special, X(), "foo")
+
+def test_do_what_I_mean(self):
+from __pypy__ import do_what_I_mean
+x = do_what_I_mean()
+assert x == 42
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy range-immutable: kill the silly speedups - sort and reverse force the list.

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: range-immutable
Changeset: r45824:d1de6e6a2438
Date: 2011-07-21 16:46 +0200
http://bitbucket.org/pypy/pypy/changeset/d1de6e6a2438/

Log:kill the silly speedups - sort and reverse force the list.

diff --git a/pypy/objspace/std/rangeobject.py b/pypy/objspace/std/rangeobject.py
--- a/pypy/objspace/std/rangeobject.py
+++ b/pypy/objspace/std/rangeobject.py
@@ -161,29 +161,6 @@
  space.wrap("pop index out of range"))
 raise FailedToImplement
 
-def list_reverse__RangeList(space, w_rangelist):
-# probably somewhat useless, but well...
-if w_rangelist.w_list is not None:
-raise FailedToImplement
-w_rangelist.start = w_rangelist.getitem_unchecked(w_rangelist.length-1)
-w_rangelist.step = -w_rangelist.step
-
-def list_sort__RangeList_None_None_ANY(space, w_rangelist, w_cmp,
-   w_keyfunc, w_reverse):
-# even more useless but fun
-has_reverse = space.is_true(w_reverse)
-if w_rangelist.w_list is not None:
-raise FailedToImplement
-if has_reverse:
-factor = -1
-else:
-factor = 1
-reverse = w_rangelist.step * factor < 0
-if reverse:
-w_rangelist.start = w_rangelist.getitem_unchecked(w_rangelist.length-1)
-w_rangelist.step = -w_rangelist.step
-return space.w_None
-
 
 class W_RangeIterObject(iterobject.W_AbstractSeqIterObject):
 pass
diff --git a/pypy/objspace/std/test/test_rangeobject.py 
b/pypy/objspace/std/test/test_rangeobject.py
--- a/pypy/objspace/std/test/test_rangeobject.py
+++ b/pypy/objspace/std/test/test_rangeobject.py
@@ -16,7 +16,6 @@
 "W_ListObject" not in __pypy__.internal_repr(r))
 return f
 """)
-cls.w_SORT_FORCES_LISTS = cls.space.wrap(False)
 
 def test_simple(self):
 result = []
@@ -44,12 +43,10 @@
 
 def test_empty_range(self):
 r = range(10, 10)
-if not self.SORT_FORCES_LISTS:
 r.sort(reverse=True)
 assert len(r) == 0
 assert list(reversed(r)) == []
 assert r[:] == []
-assert self.not_forced(r)
 
 def test_repr(self):
 r = range(5)
@@ -65,7 +62,6 @@
 def test_reverse(self):
 r = range(10)
 r.reverse()
-assert self.not_forced(r)
 assert r == range(9, -1, -1)
 r = range(3)
 r[0] = 1
@@ -74,19 +70,14 @@
 assert r == [2, 1, 1]
 
 def test_sort(self):
-if self.SORT_FORCES_LISTS:
-skip("sort() forces these lists")
 r = range(10, -1, -1)
 r.sort()
-assert self.not_forced(r)
 assert r == range(11)
 r = range(11)
 r.sort(reverse=True)
-assert self.not_forced(r)
 assert r == range(10, -1, -1)
 r = range(100)
 r[0] = 999
-assert not self.not_forced(r)
 r.sort()
 assert r == range(1, 100) + [999]
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy range-immutable: kill some dead code and make fields immutable

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: range-immutable
Changeset: r45825:143aa349dc6d
Date: 2011-07-21 16:49 +0200
http://bitbucket.org/pypy/pypy/changeset/143aa349dc6d/

Log:kill some dead code and make fields immutable

diff --git a/pypy/objspace/std/rangeobject.py b/pypy/objspace/std/rangeobject.py
--- a/pypy/objspace/std/rangeobject.py
+++ b/pypy/objspace/std/rangeobject.py
@@ -24,6 +24,8 @@
 class W_RangeListObject(W_Object):
 typedef = listtype.list_typedef
 
+_immutable_fields_ = ['start', 'step', 'length']
+
 def __init__(w_self, start, step, length):
 assert step != 0
 w_self.start = start
@@ -193,16 +195,6 @@
 w_rangeiter.index = index + 1
 return w_item
 
-# XXX __length_hint__()
-##def len__RangeIter(space,  w_rangeiter):
-##if w_rangeiter.w_seq is None:
-##return wrapint(space, 0)
-##index = w_rangeiter.index
-##w_length = space.len(w_rangeiter.w_seq)
-##w_len = space.sub(w_length, wrapint(space, index))
-##if space.is_true(space.lt(w_len, wrapint(space, 0))):
-##w_len = wrapint(space, 0)
-##return w_len
 
 registerimplementation(W_RangeListObject)
 registerimplementation(W_RangeIterObject)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: bah, I don't know why I did it, but the fix in abaf35bf5217 actually breaks things. Revert

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r45826:ebd8af15b4e6
Date: 2011-07-21 17:00 +0200
http://bitbucket.org/pypy/pypy/changeset/ebd8af15b4e6/

Log:bah, I don't know why I did it, but the fix in abaf35bf5217 actually
breaks things. Revert

diff --git a/pypy/objspace/std/dictproxyobject.py 
b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -86,7 +86,7 @@
 
 def clear(self, w_dict):
 self.unerase(w_dict.dstorage).dict_w.clear()
-self.unerase(w_dict.dstorage).mutated()
+self.unerase(w_dict.dstorage).mutated(None)
 
 class DictProxyIteratorImplementation(IteratorImplementation):
 def __init__(self, space, strategy, dictimplementation):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy range-immutable: merge default

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: range-immutable
Changeset: r45827:3e3564841c5c
Date: 2011-07-21 16:58 +0200
http://bitbucket.org/pypy/pypy/changeset/3e3564841c5c/

Log:merge default

diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -25,6 +25,7 @@
 'debug_print_once'  : 'interp_debug.debug_print_once',
 'builtinify': 'interp_magic.builtinify',
 'lookup_special': 'interp_magic.lookup_special',
+'do_what_I_mean': 'interp_magic.do_what_I_mean',
 }
 
 submodules = {
diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -70,3 +70,6 @@
 if w_descr is None:
 return space.w_None
 return space.get(w_descr, w_obj)
+
+def do_what_I_mean(space):
+return space.wrap(42)
diff --git a/pypy/module/__pypy__/test/test_special.py 
b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -49,3 +49,8 @@
 class X:
 pass
 raises(TypeError, lookup_special, X(), "foo")
+
+def test_do_what_I_mean(self):
+from __pypy__ import do_what_I_mean
+x = do_what_I_mean()
+assert x == 42
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy range-immutable: merge default again

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: range-immutable
Changeset: r45828:b93130fd5be1
Date: 2011-07-21 17:06 +0200
http://bitbucket.org/pypy/pypy/changeset/b93130fd5be1/

Log:merge default again

diff --git a/pypy/objspace/std/dictproxyobject.py 
b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -86,7 +86,7 @@
 
 def clear(self, w_dict):
 self.unerase(w_dict.dstorage).dict_w.clear()
-self.unerase(w_dict.dstorage).mutated()
+self.unerase(w_dict.dstorage).mutated(None)
 
 class DictProxyIteratorImplementation(IteratorImplementation):
 def __init__(self, space, strategy, dictimplementation):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Disable those jitdrivers for now - they break translation

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45829:558c3a321a43
Date: 2011-07-21 17:48 +0200
http://bitbucket.org/pypy/pypy/changeset/558c3a321a43/

Log:Disable those jitdrivers for now - they break translation

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
@@ -272,8 +272,8 @@
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver1.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
@@ -282,8 +282,8 @@
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver2.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add a failing test

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45830:f653dfeacbc6
Date: 2011-07-21 17:49 +0200
http://bitbucket.org/pypy/pypy/changeset/f653dfeacbc6/

Log:add a failing test

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -2586,7 +2586,23 @@
 return n
 res = self.meta_interp(f, [10, 1])
 self.check_loops(getfield_gc=2)
+assert res == f(10, 1)
 
+def test_jit_merge_point_with_raw_pointer(self):
+driver = JitDriver(greens = [], reds = ['n', 'x'])
+
+TP = lltype.Array(lltype.Signed)
+
+def f(n):
+x = lltype.malloc(TP, 10, flavor='raw')
+x[0] = 1
+while n > 0:
+driver.jit_merge_point(n=n, x=x)
+n -= x[0]
+lltype.free(x, flavor='raw')
+return n
+
+self.meta_interp(f, [10], repeat=3)
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
 pass
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix the test

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45831:531879ba26f2
Date: 2011-07-21 18:14 +0200
http://bitbucket.org/pypy/pypy/changeset/531879ba26f2/

Log:fix the test

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -2591,7 +2591,7 @@
 def test_jit_merge_point_with_raw_pointer(self):
 driver = JitDriver(greens = [], reds = ['n', 'x'])
 
-TP = lltype.Array(lltype.Signed)
+TP = lltype.Array(lltype.Signed, hints={'nolength': True})
 
 def f(n):
 x = lltype.malloc(TP, 10, flavor='raw')
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -138,6 +138,9 @@
 refvalue = cpu.ts.cast_to_ref(value)
 cpu.set_future_value_ref(j, refvalue)
 elif typecode == 'int':
+if isinstance(lltype.typeOf(value), lltype.Ptr):
+intvalue = llmemory.AddressAsInt(llmemory.cast_ptr_to_adr(value))
+else:
 intvalue = lltype.cast_primitive(lltype.Signed, value)
 cpu.set_future_value_int(j, intvalue)
 elif typecode == 'float':
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy range-immutable: merge default again x2

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: range-immutable
Changeset: r45832:a17d21b7ede9
Date: 2011-07-21 18:15 +0200
http://bitbucket.org/pypy/pypy/changeset/a17d21b7ede9/

Log:merge default again x2

diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -2586,7 +2586,23 @@
 return n
 res = self.meta_interp(f, [10, 1])
 self.check_loops(getfield_gc=2)
+assert res == f(10, 1)
 
+def test_jit_merge_point_with_raw_pointer(self):
+driver = JitDriver(greens = [], reds = ['n', 'x'])
+
+TP = lltype.Array(lltype.Signed, hints={'nolength': True})
+
+def f(n):
+x = lltype.malloc(TP, 10, flavor='raw')
+x[0] = 1
+while n > 0:
+driver.jit_merge_point(n=n, x=x)
+n -= x[0]
+lltype.free(x, flavor='raw')
+return n
+
+self.meta_interp(f, [10], repeat=3)
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
 pass
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -138,6 +138,9 @@
 refvalue = cpu.ts.cast_to_ref(value)
 cpu.set_future_value_ref(j, refvalue)
 elif typecode == 'int':
+if isinstance(lltype.typeOf(value), lltype.Ptr):
+intvalue = llmemory.AddressAsInt(llmemory.cast_ptr_to_adr(value))
+else:
 intvalue = lltype.cast_primitive(lltype.Signed, value)
 cpu.set_future_value_int(j, intvalue)
 elif typecode == 'float':
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
@@ -272,8 +272,8 @@
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver1.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
@@ -282,8 +282,8 @@
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver2.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix tests to consistenty use array descrs

2011-07-21 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r45833:2ead4778c7ac
Date: 2011-07-21 18:56 +0200
http://bitbucket.org/pypy/pypy/changeset/2ead4778c7ac/

Log:fix tests to consistenty use array descrs

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -2820,11 +2820,11 @@
 def test_residual_call_invalidate_some_arrays(self):
 ops = """
 [p1, p2, i1]
-p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+p3 = getarrayitem_gc(p2, 0, descr=arraydescr2)
 p4 = getarrayitem_gc(p2, 1, descr=arraydescr2)
 i2 = getarrayitem_gc(p1, 1, descr=arraydescr)
 i3 = call(i1, descr=writearraydescr)
-p5 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+p5 = getarrayitem_gc(p2, 0, descr=arraydescr2)
 p6 = getarrayitem_gc(p2, 1, descr=arraydescr2)
 i4 = getarrayitem_gc(p1, 1, descr=arraydescr)
 escape(p3)
@@ -2837,7 +2837,7 @@
 """
 expected = """
 [p1, p2, i1]
-p3 = getarrayitem_gc(p1, 0, descr=arraydescr2)
+p3 = getarrayitem_gc(p2, 0, descr=arraydescr2)
 p4 = getarrayitem_gc(p2, 1, descr=arraydescr2)
 i2 = getarrayitem_gc(p1, 1, descr=arraydescr)
 i3 = call(i1, descr=writearraydescr)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: numpy: changed numarray unary functions to use ufuncs

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: 
Changeset: r45834:136146a41b4a
Date: 2011-07-21 11:18 -0600
http://bitbucket.org/pypy/pypy/changeset/136146a41b4a/

Log:numpy: changed numarray unary functions to use ufuncs

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
@@ -28,12 +28,6 @@
 slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
 slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
 
-def pos(v):
-return v
-def neg(v):
-return -v
-def absolute(v):
-return abs(v)
 def add(v1, v2):
 return v1 + v2
 def mul(v1, v2):
@@ -59,21 +53,14 @@
 arr.force_if_needed()
 del self.invalidates[:]
 
-def _unop_impl(function):
-signature = Signature()
+def _unaryop_impl(w_ufunc):
 def impl(self, space):
-new_sig = self.signature.transition(signature)
-res = Call1(
-function,
-self,
-new_sig)
-self.invalidates.append(res)
-return space.wrap(res)
-return func_with_new_name(impl, "uniop_%s_impl" % function.__name__)
+return w_ufunc(space, self)
+return func_with_new_name(impl, "unaryop_%s_impl" % w_ufunc.__name__)
 
-descr_pos = _unop_impl(pos)
-descr_neg = _unop_impl(neg)
-descr_abs = _unop_impl(absolute)
+descr_pos = _unaryop_impl(interp_ufuncs.positive)
+descr_neg = _unaryop_impl(interp_ufuncs.negative)
+descr_abs = _unaryop_impl(interp_ufuncs.absolute)
 
 def _binop_impl(w_ufunc):
 def impl(self, space, w_other):
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
@@ -72,6 +72,11 @@
 def multiply(lvalue, rvalue):
 return lvalue * rvalue
 
+# Used by numarray for __pos__. Not visible from numpy application space.
+@ufunc
+def positive(value):
+return value
+
 @ufunc
 def negative(value):
 return -value
@@ -114,4 +119,4 @@
 
 @ufunc2
 def mod(lvalue, rvalue):
-return math.fmod(lvalue, rvalue)
\ No newline at end of file
+return math.fmod(lvalue, rvalue)
diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -1,7 +1,7 @@
 from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.rpython.test.test_llinterp import interpret
 from pypy.module.micronumpy.interp_numarray import (SingleDimArray, Signature,
-FloatWrapper, Call2, SingleDimSlice, add, mul, neg, Call1)
+FloatWrapper, Call2, SingleDimSlice, add, mul, Call1)
 from pypy.module.micronumpy.interp_ufuncs import negative
 from pypy.module.micronumpy.compile import numpy_compile
 from pypy.rlib.objectmodel import specialize
@@ -48,19 +48,6 @@
   "int_lt": 1, "guard_true": 1, "jump": 1})
 assert result == f(5)
 
-def test_neg(self):
-def f(i):
-ar = SingleDimArray(i)
-v = Call1(neg, ar, Signature())
-return v.get_concrete().storage[3]
-
-result = self.meta_interp(f, [5], listops=True, backendopt=True)
-self.check_loops({"getarrayitem_raw": 1, "float_neg": 1,
-  "setarrayitem_raw": 1, "int_add": 1,
-  "int_lt": 1, "guard_true": 1, "jump": 1})
-
-assert result == f(5)
-
 def test_sum(self):
 space = self.space
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merged unary functs

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: 
Changeset: r45835:9b3ddfcb4c38
Date: 2011-07-21 11:20 -0600
http://bitbucket.org/pypy/pypy/changeset/9b3ddfcb4c38/

Log:merged unary functs

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
@@ -28,12 +28,6 @@
 slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
 slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
 
-def pos(v):
-return v
-def neg(v):
-return -v
-def absolute(v):
-return abs(v)
 def add(v1, v2):
 return v1 + v2
 def mul(v1, v2):
@@ -59,21 +53,14 @@
 arr.force_if_needed()
 del self.invalidates[:]
 
-def _unop_impl(function):
-signature = Signature()
+def _unaryop_impl(w_ufunc):
 def impl(self, space):
-new_sig = self.signature.transition(signature)
-res = Call1(
-function,
-self,
-new_sig)
-self.invalidates.append(res)
-return space.wrap(res)
-return func_with_new_name(impl, "uniop_%s_impl" % function.__name__)
+return w_ufunc(space, self)
+return func_with_new_name(impl, "unaryop_%s_impl" % w_ufunc.__name__)
 
-descr_pos = _unop_impl(pos)
-descr_neg = _unop_impl(neg)
-descr_abs = _unop_impl(absolute)
+descr_pos = _unaryop_impl(interp_ufuncs.positive)
+descr_neg = _unaryop_impl(interp_ufuncs.negative)
+descr_abs = _unaryop_impl(interp_ufuncs.absolute)
 
 def _binop_impl(w_ufunc):
 def impl(self, space, w_other):
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
@@ -72,6 +72,11 @@
 def multiply(lvalue, rvalue):
 return lvalue * rvalue
 
+# Used by numarray for __pos__. Not visible from numpy application space.
+@ufunc
+def positive(value):
+return value
+
 @ufunc
 def negative(value):
 return -value
@@ -114,4 +119,4 @@
 
 @ufunc2
 def mod(lvalue, rvalue):
-return math.fmod(lvalue, rvalue)
\ No newline at end of file
+return math.fmod(lvalue, rvalue)
diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -1,7 +1,7 @@
 from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.rpython.test.test_llinterp import interpret
 from pypy.module.micronumpy.interp_numarray import (SingleDimArray, Signature,
-FloatWrapper, Call2, SingleDimSlice, add, mul, neg, Call1)
+FloatWrapper, Call2, SingleDimSlice, add, mul, Call1)
 from pypy.module.micronumpy.interp_ufuncs import negative
 from pypy.module.micronumpy.compile import numpy_compile
 from pypy.rlib.objectmodel import specialize
@@ -48,19 +48,6 @@
   "int_lt": 1, "guard_true": 1, "jump": 1})
 assert result == f(5)
 
-def test_neg(self):
-def f(i):
-ar = SingleDimArray(i)
-v = Call1(neg, ar, Signature())
-return v.get_concrete().storage[3]
-
-result = self.meta_interp(f, [5], listops=True, backendopt=True)
-self.check_loops({"getarrayitem_raw": 1, "float_neg": 1,
-  "setarrayitem_raw": 1, "int_add": 1,
-  "int_lt": 1, "guard_true": 1, "jump": 1})
-
-assert result == f(5)
-
 def test_sum(self):
 space = self.space
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: done

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: extradoc
Changeset: r3837:886df227da76
Date: 2011-07-21 19:22 +0200
http://bitbucket.org/pypy/extradoc/changeset/886df227da76/

Log:done

diff --git a/planning/jit.txt b/planning/jit.txt
--- a/planning/jit.txt
+++ b/planning/jit.txt
@@ -8,11 +8,6 @@
   [arigo] - cpython has sys._current_frames(), but not pypy; however
 relying on this looks like it's not the job of the jit
 
-* we should run nightly 64bit benchmarks. As of mid-April, richards
-  was noticably (30-50%) slower on 64bit than 32bit. I didn't notice
-  other benchmarks, but since we don't run it, we don't have a way
-  to compare.
-
 NEW TASKS
 -
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Re-enable set slice drivers for numarrays for that the zjit tests succeed.

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: 
Changeset: r45836:acad170d7ecf
Date: 2011-07-21 11:39 -0600
http://bitbucket.org/pypy/pypy/changeset/acad170d7ecf/

Log:Re-enable set slice drivers for numarrays for that the zjit tests
succeed.

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
@@ -259,8 +259,8 @@
 i = start
 j = 0
 while i < stop:
-#slice_driver1.jit_merge_point(signature=arr.signature,
-#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+slice_driver1.jit_merge_point(signature=arr.signature,
+step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
@@ -269,8 +269,8 @@
 i = start
 j = 0
 while i > stop:
-#slice_driver2.jit_merge_point(signature=arr.signature,
-#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+slice_driver2.jit_merge_point(signature=arr.signature,
+step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-short_from_state: produce guards before forcing virtuals as one force might lead to another

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45837:3c2afbf75c4a
Date: 2011-07-21 20:37 +0200
http://bitbucket.org/pypy/pypy/changeset/3c2afbf75c4a/

Log:produce guards before forcing virtuals as one force might lead to
another

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -6579,6 +6579,20 @@
 """
 self.optimize_loop(ops, expected)
 
+def test_chained_virtuals(self):
+ops = """
+[p0, p1]
+p2 = new_with_vtable(ConstClass(node_vtable))
+p3 = new_with_vtable(ConstClass(node_vtable))
+setfield_gc(p2, p3, descr=nextdescr) 
+jump(p2, p3)
+"""
+expected = """
+[]
+jump()
+"""
+self.optimize_loop(ops, expected)
+
 def test_arraylen_bound(self):
 ops = """
 [p1, i]
diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py 
b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -217,15 +217,18 @@
 inputarg_setup_ops = []
 preamble_optimizer.newoperations = []
 seen = {}
+for box in inputargs:
+if box in seen:
+continue
+seen[box] = True
+value = preamble_optimizer.getvalue(box)
+inputarg_setup_ops.extend(value.make_guards(box))
 for box in short_inputargs:
 if box in seen:
 continue
 seen[box] = True
 value = preamble_optimizer.getvalue(box)
-if value.is_virtual():
 value.force_box()
-else:
-inputarg_setup_ops.extend(value.make_guards(box))
 preamble_optimizer.flush()
 inputarg_setup_ops += preamble_optimizer.newoperations
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-short_from_state: fix test

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45838:5b76193812ac
Date: 2011-07-21 20:43 +0200
http://bitbucket.org/pypy/pypy/changeset/5b76193812ac/

Log:fix test

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -5139,8 +5139,8 @@
 ops = """
 [p0, p1, p2, p3, i4, p5, i6, p7, p8, p9, p14]
 guard_value(i4, 3) []
-guard_class(p9, 17278984) []
-guard_class(p9, 17278984) []
+guard_class(p9, ConstClass(node_vtable)) []
+guard_class(p9, ConstClass(node_vtable)) []
 p22 = getfield_gc(p9, descr=inst_w_seq)
 guard_nonnull(p22) []
 i23 = getfield_gc(p9, descr=inst_index)
@@ -5155,11 +5155,11 @@
 guard_class(p14, 17273920) []
 guard_class(p14, 17273920) []
 
-p75 = new_with_vtable(17278984)
+p75 = new_with_vtable(ConstClass(node_vtable))
 setfield_gc(p75, p14, descr=inst_w_seq)
 setfield_gc(p75, 0, descr=inst_index)
-guard_class(p75, 17278984) []
-guard_class(p75, 17278984) []
+guard_class(p75, ConstClass(node_vtable)) []
+guard_class(p75, ConstClass(node_vtable)) []
 p79 = getfield_gc(p75, descr=inst_w_seq)
 guard_nonnull(p79) []
 i80 = getfield_gc(p75, descr=inst_index)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-short_from_state: variable index strgetitem nolong cached across loop boundaries

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45839:aad66f8cf6be
Date: 2011-07-21 20:46 +0200
http://bitbucket.org/pypy/pypy/changeset/aad66f8cf6be/

Log:variable index strgetitem nolong cached across loop boundaries

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -5610,6 +5610,7 @@
 ops = """
 [p0, i0]
 i1 = strgetitem(p0, i0)
+i10 = strgetitem(p0, i0)
 i2 = int_lt(i1, 256)
 guard_true(i2) []
 i3 = int_ge(i1, 0)
@@ -5618,6 +5619,7 @@
 """
 expected = """
 [p0, i0]
+i1 = strgetitem(p0, i0)
 jump(p0, i0)
 """
 self.optimize_loop(ops, expected)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-short_from_state: variable index unicodegetitem nolong cached across loop boundaries

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45840:1bf3cbdade3a
Date: 2011-07-21 20:46 +0200
http://bitbucket.org/pypy/pypy/changeset/1bf3cbdade3a/

Log:variable index unicodegetitem nolong cached across loop boundaries

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -5628,12 +5628,14 @@
 ops = """
 [p0, i0]
 i1 = unicodegetitem(p0, i0)
+i10 = unicodegetitem(p0, i0)
 i2 = int_lt(i1, 0)
 guard_false(i2) []
 jump(p0, i0)
 """
 expected = """
 [p0, i0]
+i1 = unicodegetitem(p0, i0)
 jump(p0, i0)
 """
 self.optimize_loop(ops, expected)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-short_from_state: fixed test

2011-07-21 Thread hakanardo
Author: Hakan Ardo 
Branch: jit-short_from_state
Changeset: r45841:74ad7bd66501
Date: 2011-07-21 20:55 +0200
http://bitbucket.org/pypy/pypy/changeset/74ad7bd66501/

Log:fixed test

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -6653,8 +6653,8 @@
 ops = """
 [p0]
 p1 = getfield_gc(p0, descr=nextdescr)
-p2 = strgetitem(p1, 7)
-call(p2, descr=nonwritedescr)
+i22 = strgetitem(p1, 7)
+call(i22, descr=nonwritedescr)
 jump(p0)
 """
 short = """
@@ -6664,17 +6664,17 @@
 i1 = strlen(p1)
 i2 = int_ge(i1, 8)
 guard_true(i2) []
-p2 = strgetitem(p1, 7, descr=)
-i8 = int_ge(p2, 0)
+i22 = strgetitem(p1, 7, descr=)
+i8 = int_ge(i22, 0)
 guard_true(i8) []
-i9 = int_le(p2, 255)
+i9 = int_le(i22, 255)
 guard_true(i9) []
-jump(p0, p2)
-"""
-expected = """
-[p0, p2]
-call(p2, descr=nonwritedescr)
-jump(p0, p2)
+jump(p0, i22)
+"""
+expected = """
+[p0, i22]
+call(i22, descr=nonwritedescr)
+jump(p0, i22)
 """
 self.optimize_loop(ops, expected, expected_short=short)
 
@@ -6682,8 +6682,8 @@
 ops = """
 [p0]
 p1 = getfield_gc(p0, descr=nextdescr)
-p2 = unicodegetitem(p1, 7)
-call(p2, descr=nonwritedescr)
+i22 = unicodegetitem(p1, 7)
+call(i22, descr=nonwritedescr)
 jump(p0)
 """
 short = """
@@ -6693,15 +6693,15 @@
 i1 = unicodelen(p1)
 i2 = int_ge(i1, 8)
 guard_true(i2) []
-p2 = unicodegetitem(p1, 7, descr=)
-i8 = int_ge(p2, 0)
+i22 = unicodegetitem(p1, 7, descr=)
+i8 = int_ge(i22, 0)
 guard_true(i8) []
-jump(p0, p2)
-"""
-expected = """
-[p0, p2]
-call(p2, descr=nonwritedescr)
-jump(p0, p2)
+jump(p0, i22)
+"""
+expected = """
+[p0, i22]
+call(i22, descr=nonwritedescr)
+jump(p0, i22)
 """
 self.optimize_loop(ops, expected, expected_short=short)
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ootype-rerased: Added test for oo{, un}box_integer. Currently fails.

2011-07-21 Thread ademan
Author: Daniel Roberts 
Branch: ootype-rerased
Changeset: r45842:3af86a0633cc
Date: 2011-07-21 12:12 -0700
http://bitbucket.org/pypy/pypy/changeset/3af86a0633cc/

Log:Added test for oo{,un}box_integer. Currently fails.

diff --git a/pypy/rpython/lltypesystem/lloperation.py 
b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -585,6 +585,8 @@
 'classof':  LLOp(oo=True, canfold=True),
 'subclassof':   LLOp(oo=True, canfold=True),
 'oostring': LLOp(oo=True, sideeffects=False),
+'oobox_int':LLOp(oo=True, sideeffects=False),
+'oounbox_int':  LLOp(oo=True, sideeffects=False),
 'ooparse_int':  LLOp(oo=True, canraise=(ValueError,)),
 'ooparse_float':LLOp(oo=True, canraise=(ValueError,)),
 'oounicode':LLOp(oo=True, canraise=(UnicodeDecodeError,)),
diff --git a/pypy/translator/oosupport/test_template/operations.py 
b/pypy/translator/oosupport/test_template/operations.py
--- a/pypy/translator/oosupport/test_template/operations.py
+++ b/pypy/translator/oosupport/test_template/operations.py
@@ -1,3 +1,6 @@
+from pypy.rpython.lltypesystem.lloperation import llop
+from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.ootypesystem import ootype
 from pypy.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong, ovfcheck
 from pypy.rlib import rstack
 from pypy.annotation import model as annmodel
@@ -204,6 +207,13 @@
 return bool(x)
 self._check_all(fn)
 
+def test_box(self):
+def f():
+x = 42
+y = llop.oobox_int(ootype.Object, x)
+return llop.oounbox_int(lltype.Signed, y)
+assert self.interpret(f, []) == 42
+
 def test_ullong_rshift(self):
 def f(x):
 return x >> 1
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: inline the pytest coverage plugin, and autoload it in pypy/test_all.py

2011-07-21 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt 
Branch: 
Changeset: r45843:b1ae5324c66b
Date: 2011-07-21 23:37 +0200
http://bitbucket.org/pypy/pypy/changeset/b1ae5324c66b/

Log:inline the pytest coverage plugin, and autoload it in
pypy/test_all.py

diff --git a/pypy/test_all.py b/pypy/test_all.py
--- a/pypy/test_all.py
+++ b/pypy/test_all.py
@@ -18,4 +18,5 @@
 if __name__ == '__main__':
 import tool.autopath
 import pytest
-sys.exit(pytest.main())
+import pytest_cov
+sys.exit(pytest.main(plugins=[pytest_cov]))
diff --git a/pytest_cov.py b/pytest_cov.py
new file mode 100644
--- /dev/null
+++ b/pytest_cov.py
@@ -0,0 +1,351 @@
+"""produce code coverage reports using the 'coverage' package, including 
support for distributed testing.
+
+This plugin produces coverage reports.  It supports centralised testing and 
distributed testing in
+both load and each modes.  It also supports coverage of subprocesses.
+
+All features offered by the coverage package should be available, either 
through pytest-cov or
+through coverage's config file.
+
+
+Installation
+
+
+The `pytest-cov`_ package may be installed with pip or easy_install::
+
+pip install pytest-cov
+easy_install pytest-cov
+
+.. _`pytest-cov`: http://pypi.python.org/pypi/pytest-cov/
+
+
+Uninstallation
+--
+
+Uninstalling packages is supported by pip::
+
+pip uninstall pytest-cov
+
+However easy_install does not provide an uninstall facility.
+
+.. IMPORTANT::
+
+Ensure that you manually delete the init_cov_core.pth file in your 
site-packages directory.
+
+This file starts coverage collection of subprocesses if appropriate during 
site initialisation
+at python startup.
+
+
+Usage
+-
+
+Centralised Testing
+~~~
+
+Centralised testing will report on the combined coverage of the main process 
and all of it's
+subprocesses.
+
+Running centralised testing::
+
+py.test --cov myproj tests/
+
+Shows a terminal report::
+
+ coverage: platform linux2, python 2.6.4-final-0 
-
+Name Stmts   Miss  Cover
+
+myproj/__init__  2  0   100%
+myproj/myproj  257 1394%
+myproj/feature4286  94  792%
+
+TOTAL  353 2094%
+
+
+Distributed Testing: Load
+~
+
+Distributed testing with dist mode set to load will report on the combined 
coverage of all slaves.
+The slaves may be spread out over any number of hosts and each slave may be 
located anywhere on the
+file system.  Each slave will have it's subprocesses measured.
+
+Running distributed testing with dist mode set to load::
+
+py.test --cov myproj -n 2 tests/
+
+Shows a terminal report::
+
+ coverage: platform linux2, python 2.6.4-final-0 
-
+Name Stmts   Miss  Cover
+
+myproj/__init__  2  0   100%
+myproj/myproj  257 1394%
+myproj/feature4286  94  792%
+
+TOTAL  353 2094%
+
+
+Again but spread over different hosts and different directories::
+
+py.test --cov myproj --dist load
+--tx ssh=memedough@host1//chdir=testenv1
+--tx 
ssh=memedough@host2//chdir=/tmp/testenv2//python=/tmp/env1/bin/python
+--rsyncdir myproj --rsyncdir tests --rsync examples
+tests/
+
+Shows a terminal report::
+
+ coverage: platform linux2, python 2.6.4-final-0 
-
+Name Stmts   Miss  Cover
+
+myproj/__init__  2  0   100%
+myproj/myproj  257 1394%
+myproj/feature4286  94  792%
+
+TOTAL  353 2094%
+
+
+Distributed Testing: Each
+~
+
+Distributed testing with dist mode set to each will report on the combined 
coverage of all slaves.
+Since each slave is running all tests this allows generating a combined 
coverage report for multiple
+environments.
+
+Running distributed testing with dist mode set to each::
+
+py.test --cov myproj --dist each
+--tx 
popen//chdir=/tmp/testenv3//python=/usr/local/python27/bin/python
+--tx 
ssh=memedough@host2//chdir=/tmp/testenv4//python=/tmp/env2/bin/python
+--rsyncdir myproj --rsyncdir tests --rsync examples
+tests/
+
+Shows a terminal report::
+
+ coverage 

+  platform linux2, python 2.6.5-final-0
+  platform linux2, python 2.7.0-final-0
+Name Stmt

[pypy-commit] pypy default: disable those until we know it works

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45844:cb95026e7622
Date: 2011-07-21 23:46 +0200
http://bitbucket.org/pypy/pypy/changeset/cb95026e7622/

Log:disable those until we know it works

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
@@ -259,8 +259,8 @@
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver1.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
@@ -269,8 +269,8 @@
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver2.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ootype-rerased: fix the signature of the oo{box, unbox}_int java methods

2011-07-21 Thread antocuni
Author: Antonio Cuni 
Branch: ootype-rerased
Changeset: r45845:21953bca75cb
Date: 2011-07-21 23:55 +0200
http://bitbucket.org/pypy/pypy/changeset/21953bca75cb/

Log:fix the signature of the oo{box,unbox}_int java methods

diff --git a/pypy/translator/jvm/typesystem.py 
b/pypy/translator/jvm/typesystem.py
--- a/pypy/translator/jvm/typesystem.py
+++ b/pypy/translator/jvm/typesystem.py
@@ -963,8 +963,8 @@
 PYPYRUNTIMENEW =Method.s(jPyPy, 'RuntimeNew', (jClass,), jObject)
 PYPYSTRING2BYTES =  Method.s(jPyPy, 'string2bytes', (jString,), jByteArray)
 PYPYARRAYTOLIST =   Method.s(jPyPy, 'array_to_list', (jObjectArray,), 
jArrayList)
-PYPYBOXINT =Method.s(jPyPy, 'box_integer', (jInt,), jIntegerClass)
-PYPYUNBOXINT =  Method.s(jPyPy, 'unbox_integer', (jIntegerClass,), 
jInt)
+PYPYBOXINT =Method.s(jPyPy, 'box_integer', (jInt,), jObject)
+PYPYUNBOXINT =  Method.s(jPyPy, 'unbox_integer', (jObject,), jInt)
 PYPYOOPARSEFLOAT =  Method.v(jPyPy, 'ooparse_float', (jString,), jDouble)
 OBJECTGETCLASS =Method.v(jObject, 'getClass', (), jClass)
 CLASSGETNAME =  Method.v(jClass, 'getName', (), jString)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: respect CFLAGS when installing stuff with distutils.

2011-07-21 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r45846:7203ebd350a7
Date: 2011-07-21 15:13 -0700
http://bitbucket.org/pypy/pypy/changeset/7203ebd350a7/

Log:respect CFLAGS when installing stuff with distutils.

diff --git a/lib-python/modified-2.7/distutils/sysconfig_pypy.py 
b/lib-python/modified-2.7/distutils/sysconfig_pypy.py
--- a/lib-python/modified-2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/modified-2.7/distutils/sysconfig_pypy.py
@@ -116,6 +116,12 @@
 if compiler.compiler_type == "unix":
 compiler.compiler_so.extend(['-fPIC', '-Wimplicit'])
 compiler.shared_lib_extension = get_config_var('SO')
+if "CFLAGS" in os.environ:
+cflags = os.environ["CFLAGS"]
+compiler.compiler.append(cflags)
+compiler.compiler_so.append(cflags)
+compiler.linker_so.append(cflags)
+
 
 from sysconfig_cpython import (
 parse_makefile, _variable_rx, expand_makefile_vars)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: also use pytest_cov in the normal pytest script

2011-07-21 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt 
Branch: 
Changeset: r45847:ff4a90f9be99
Date: 2011-07-21 23:59 +0200
http://bitbucket.org/pypy/pypy/changeset/ff4a90f9be99/

Log:also use pytest_cov in the normal pytest script

diff --git a/pytest.py b/pytest.py
--- a/pytest.py
+++ b/pytest.py
@@ -9,6 +9,8 @@
 from _pytest import __version__
 
 if __name__ == '__main__': # if run as a script or by 'python -m pytest'
-raise SystemExit(main())
+#XXX: sync to upstream later
+import pytest_cov
+raise SystemExit(main(plugins=[pytest_cov]))
 else:
 _preloadplugins() # to populate pytest.* namespace so help(pytest) works
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: mark the xdist hooks of pytest_cov optional

2011-07-21 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt 
Branch: 
Changeset: r45848:e16267c17fb1
Date: 2011-07-22 00:21 +0200
http://bitbucket.org/pypy/pypy/changeset/e16267c17fb1/

Log:mark the xdist hooks of pytest_cov optional

diff --git a/pytest_cov.py b/pytest_cov.py
--- a/pytest_cov.py
+++ b/pytest_cov.py
@@ -323,11 +323,13 @@
 """Delegate to our implementation."""
 
 self.cov_controller.configure_node(node)
+pytest_configure_node.optionalhook = True
 
 def pytest_testnodedown(self, node, error):
 """Delegate to our implementation."""
 
 self.cov_controller.testnodedown(node, error)
+pytest_testnodedown.optionalhook = True
 
 def pytest_sessionfinish(self, session, exitstatus):
 """Delegate to our implementation."""
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge

2011-07-21 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt 
Branch: 
Changeset: r45849:cededc37c18e
Date: 2011-07-22 00:22 +0200
http://bitbucket.org/pypy/pypy/changeset/cededc37c18e/

Log:merge

diff --git a/lib-python/modified-2.7/distutils/sysconfig_pypy.py 
b/lib-python/modified-2.7/distutils/sysconfig_pypy.py
--- a/lib-python/modified-2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/modified-2.7/distutils/sysconfig_pypy.py
@@ -116,6 +116,12 @@
 if compiler.compiler_type == "unix":
 compiler.compiler_so.extend(['-fPIC', '-Wimplicit'])
 compiler.shared_lib_extension = get_config_var('SO')
+if "CFLAGS" in os.environ:
+cflags = os.environ["CFLAGS"]
+compiler.compiler.append(cflags)
+compiler.compiler_so.append(cflags)
+compiler.linker_so.append(cflags)
+
 
 from sysconfig_cpython import (
 parse_makefile, _variable_rx, expand_makefile_vars)
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
@@ -259,8 +259,8 @@
 i = start
 j = 0
 while i < stop:
-slice_driver1.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver1.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
@@ -269,8 +269,8 @@
 i = start
 j = 0
 while i > stop:
-slice_driver2.jit_merge_point(signature=arr.signature,
-step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
+#slice_driver2.jit_merge_point(signature=arr.signature,
+#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
 storage[i] = arr.eval(j)
 j += 1
 i += step
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add using coverage reports to the coding guide

2011-07-21 Thread RonnyPfannschmidt
Author: Ronny Pfannschmidt 
Branch: 
Changeset: r45850:38aa87797a59
Date: 2011-07-22 00:45 +0200
http://bitbucket.org/pypy/pypy/changeset/38aa87797a59/

Log:add using coverage reports to the coding guide

diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -929,6 +929,19 @@
 located in the ``py/bin/`` directory.  For switches to
 modify test execution pass the ``-h`` option.
 
+Coverage reports
+
+
+In order to get coverage reports the `pytest-cov`_ plugin is included.
+it adds some extra requirements ( coverage_ and `cov-core`_ )
+and can once they are installed coverage testing can be invoked via::
+
+  python test_all.py --cov file_or_direcory_to_cover file_or_directory
+
+.. _`pytest-cov`: http://pypi.python.org/pypi/pytest-cov
+.. _`coverage`: http://pypi.python.org/pypi/coverage
+.. _`cov-core`: http://pypi.python.org/pypi/cov-core
+
 Test conventions
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: kill some dead code

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45851:d6837e825d00
Date: 2011-07-22 00:49 +0200
http://bitbucket.org/pypy/pypy/changeset/d6837e825d00/

Log:kill some dead code

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
@@ -11,14 +11,6 @@
 from pypy.tool.sourcetools import func_with_new_name
 import math
 
-def dummy1(v):
-assert isinstance(v, float)
-return v
-
-def dummy2(v):
-assert isinstance(v, float)
-return v
-
 TP = lltype.Array(lltype.Float, hints={'nolength': True})
 
 numpy_driver = jit.JitDriver(greens = ['signature'],
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: a missing test

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45852:7b3a66f3c80a
Date: 2011-07-22 00:56 +0200
http://bitbucket.org/pypy/pypy/changeset/7b3a66f3c80a/

Log:a missing test

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
@@ -171,6 +171,10 @@
 for i in range(5):
 assert b[i] == i + 5
 
+def test_radd(self):
+from numpy import array
+assert 3 + array(range(3)) == array([3, 4, 5])
+
 def test_add_list(self):
 from numpy import array
 a = array(range(5))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix the test, thanks justin

2011-07-21 Thread fijal
Author: Maciej Fijalkowski 
Branch: 
Changeset: r45853:9b2cf174334c
Date: 2011-07-22 01:05 +0200
http://bitbucket.org/pypy/pypy/changeset/9b2cf174334c/

Log:fix the test, thanks justin

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
@@ -173,7 +173,9 @@
 
 def test_radd(self):
 from numpy import array
-assert 3 + array(range(3)) == array([3, 4, 5])
+r = 3 + array(range(3))\
+for i in range(3):
+assert r[i] == i + 3
 
 def test_add_list(self):
 from numpy import array
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fixed numpy's setslice to play nicely with the jit.

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: 
Changeset: r45854:631e083bd996
Date: 2011-07-21 19:20 -0600
http://bitbucket.org/pypy/pypy/changeset/631e083bd996/

Log:fixed numpy's setslice to play nicely with the jit.

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
@@ -17,8 +17,8 @@
  reds = ['result_size', 'i', 'self', 'result'])
 all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
 any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self'])
-slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
-slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'storage', 'arr'])
+slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'source', 'dest'])
+slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 
'stop', 'source', 'dest'])
 
 def add(v1, v2):
 return v1 + v2
@@ -247,23 +247,25 @@
 def descr_mean(self, space):
 return 
space.wrap(space.float_w(self.descr_sum(space))/self.find_size())
 
-def _sliceloop1(self, start, stop, step, arr, storage):
+def _sliceloop1(self, start, stop, step, source, dest):
 i = start
 j = 0
 while i < stop:
-#slice_driver1.jit_merge_point(signature=arr.signature,
-#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
-storage[i] = arr.eval(j)
+slice_driver1.jit_merge_point(signature=source.signature,
+step=step, stop=stop, i=i, j=j, source=source,
+dest=dest)
+dest.storage[i] = source.eval(j)
 j += 1
 i += step
 
-def _sliceloop2(self, start, stop, step, arr, storage):
+def _sliceloop2(self, start, stop, step, source, dest):
 i = start
 j = 0
 while i > stop:
-#slice_driver2.jit_merge_point(signature=arr.signature,
-#step=step, stop=stop, i=i, j=j, arr=arr, storage=storage)
-storage[i] = arr.eval(j)
+slice_driver2.jit_merge_point(signature=source.signature,
+step=step, stop=stop, i=i, j=j, source=source,
+dest=dest)
+dest.storage[i] = source.eval(j)
 j += 1
 i += step
 
@@ -448,9 +450,9 @@
 stop = self.calc_index(stop)
 step = self.step * step
 if step > 0:
-self._sliceloop1(start, stop, step, arr, self.parent.storage)
+self._sliceloop1(start, stop, step, arr, self.parent)
 else:
-self._sliceloop2(start, stop, step, arr, self.parent.storage)
+self._sliceloop2(start, stop, step, arr, self.parent)
 
 def calc_index(self, item):
 return (self.start + item * self.step)
@@ -489,9 +491,9 @@
 if not isinstance(arr, BaseArray):
 arr = convert_to_array(space, arr)
 if step > 0:
-self._sliceloop1(start, stop, step, arr, self.storage)
+self._sliceloop1(start, stop, step, arr, self)
 else:
-self._sliceloop2(start, stop, step, arr, self.storage)
+self._sliceloop2(start, stop, step, arr, self)
 
 def __del__(self):
 lltype.free(self.storage, flavor='raw')
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fixed a typo in a test

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: 
Changeset: r45855:cc2ae015c7fb
Date: 2011-07-21 20:22 -0600
http://bitbucket.org/pypy/pypy/changeset/cc2ae015c7fb/

Log:Fixed a typo in a test

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
@@ -173,7 +173,7 @@
 
 def test_radd(self):
 from numpy import array
-r = 3 + array(range(3))\
+r = 3 + array(range(3))
 for i in range(3):
 assert r[i] == i + 3
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy streamio-bufout: close for merge

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: streamio-bufout
Changeset: r45857:89c23d06a9c3
Date: 2011-07-22 00:44 -0600
http://bitbucket.org/pypy/pypy/changeset/89c23d06a9c3/

Log:close for merge

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merged streamio-bufout

2011-07-21 Thread justinpeel
Author: Justin Peel 
Branch: 
Changeset: r45858:a02ff8434e20
Date: 2011-07-22 00:48 -0600
http://bitbucket.org/pypy/pypy/changeset/a02ff8434e20/

Log:merged streamio-bufout

diff --git a/pypy/rlib/streamio.py b/pypy/rlib/streamio.py
--- a/pypy/rlib/streamio.py
+++ b/pypy/rlib/streamio.py
@@ -875,28 +875,32 @@
 if bufsize == -1: # Get default from the class
 bufsize = self.bufsize
 self.bufsize = bufsize  # buffer size (hint only)
-self.buf = ""
+self.buf = []
+self.buflen = 0
 
 def flush_buffers(self):
 if self.buf:
-self.do_write(self.buf)
-self.buf = ""
+self.do_write(''.join(self.buf))
+self.buf = []
+self.buflen = 0
 
 def tell(self):
-return self.do_tell() + len(self.buf)
+return self.do_tell() + self.buflen
 
 def write(self, data):
-buflen = len(self.buf)
+buflen = self.buflen
 datalen = len(data)
 if datalen + buflen < self.bufsize:
-self.buf += data
+self.buf.append(data)
+self.buflen += datalen
 elif buflen:
-slice = self.bufsize - buflen
-assert slice >= 0
-self.buf += data[:slice]
-self.do_write(self.buf)
-self.buf = ""
-self.write(data[slice:])
+i = self.bufsize - buflen
+assert i >= 0
+self.buf.append(data[:i])
+self.do_write(''.join(self.buf))
+self.buf = []
+self.buflen = 0
+self.write(data[i:])
 else:
 self.do_write(data)
 
@@ -922,11 +926,27 @@
 """
 
 def write(self, data):
-BufferingOutputStream.write(self, data)
-p = self.buf.rfind('\n') + 1
-if p >= 0:
-self.do_write(self.buf[:p])
-self.buf = self.buf[p:]
+p = data.rfind('\n') + 1
+assert p >= 0
+if self.buflen + len(data) < self.bufsize:
+if p == 0:
+self.buf.append(data)
+self.buflen += len(data)
+else:
+if self.buflen:
+self.do_write(''.join(self.buf))
+self.do_write(data[:p])
+self.buf = [data[p:]]
+self.buflen = len(self.buf[0])
+else:
+if self.buflen + p < self.bufsize:
+p = self.bufsize - self.buflen
+if self.buflen:
+self.do_write(''.join(self.buf))
+assert p >= 0
+self.do_write(data[:p])
+self.buf = [data[p:]]
+self.buflen = len(self.buf[0])
 
 
 # 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit