Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-reintroduce-zjit-tests
Changeset: r57842:330b40485c02
Date: 2012-10-07 11:04 +0200
http://bitbucket.org/pypy/pypy/changeset/330b40485c02/
Log: in-progress, waiting for some other branch
diff --git a/pypy/annotation/test/test_annrpython.py
b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -2524,6 +2524,36 @@
s = a.build_types(f, [])
assert s.const == 2
+ def test_mixin_staticmethod(self):
+ class A(object):
+ _mixin_ = True
+
+ def __init__(self, v):
+ self.v = v
+
+ @staticmethod
+ def x(foo):
+ return len(foo)
+
+ def m(self):
+ return self.x(self.v)
+
+ class B(A):
+ pass
+
+ class C(A):
+ pass
+
+ def f(i):
+ if i:
+ return B([1, 2, 3]).m()
+ else:
+ return C("xyz").m()
+
+ a = self.RPythonAnnotator()
+ s = a.build_types(f, [int])
+ assert isinstance(s, annmodel.SomeInteger)
+
def test___class___attribute(self):
class Base(object): pass
class A(Base): pass
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
@@ -122,9 +122,10 @@
# XXX deal with the bridge at some point
self.check_simple_loop({'raw_load':2, 'float_add': 1,
'raw_store': 1, 'getarrayitem_gc': 3,
- 'getarrayitem_gc_pure': 1, 'int_add': 2,
- 'int_sub': 1, 'setfield_gc': 1,
+ 'getarrayitem_gc_pure': 1, 'int_add': 3,
+ 'int_sub': 1, 'setfield_gc': 2,
'int_lt': 1, 'guard_true': 1,
+ 'jump': 1,
'setarrayitem_gc': 1})
def define_max():
@@ -139,7 +140,8 @@
assert result == 128
self.check_simple_loop({"raw_load": 1, "float_gt": 1,
"guard_false": 2, "int_add": 1,
- "int_ge": 1, "setfield_gc": 1})
+ "int_ge": 1, "setfield_gc": 1,
+ 'jump': 1})
def define_any():
return """
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -257,8 +257,8 @@
@specialize.argtype(1)
def box(self, value):
- box = Primitive.box(self, value)
- if box.value:
+ value = lookup_type_dict(lltype.typeOf(value)).for_computation(value)
+ if value:
return self.True
else:
return self.False
@@ -276,7 +276,8 @@
def str_format(self, box):
return "True" if self.unbox(box) else "False"
- def for_computation(self, v):
+ @staticmethod
+ def for_computation(v):
return int(v)
def default_fromstring(self, space):
@@ -311,7 +312,8 @@
def str_format(self, box):
return str(self.for_computation(self.unbox(box)))
- def for_computation(self, v):
+ @staticmethod
+ def for_computation(v):
return widen(v)
def default_fromstring(self, space):
@@ -556,7 +558,8 @@
return float2string(self.for_computation(self.unbox(box)), "g",
rfloat.DTSF_STR_PRECISION)
- def for_computation(self, v):
+ @staticmethod
+ def for_computation(v):
return float(v)
def default_fromstring(self, space):
@@ -986,10 +989,18 @@
break
del tp
+TYPE_DICT = {}
+
def _setup():
# compute alignment
for tp in globals().values():
if isinstance(tp, type) and hasattr(tp, 'T'):
tp.alignment = clibffi.cast_type_to_ffitype(tp.T).c_alignment
+ TYPE_DICT[tp.T] = tp
+
[email protected]()
+def lookup_type_dict(T):
+ return TYPE_DICT[T]
+
_setup()
del _setup
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit