Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r69569:03465c3e4130
Date: 2014-03-01 00:18 -0500
http://bitbucket.org/pypy/pypy/changeset/03465c3e4130/

Log:    adjust array iter

diff --git a/pypy/module/micronumpy/iterators.py 
b/pypy/module/micronumpy/iterators.py
--- a/pypy/module/micronumpy/iterators.py
+++ b/pypy/module/micronumpy/iterators.py
@@ -80,7 +80,7 @@
 
 class ArrayIter(object):
     _immutable_fields_ = ['array', 'size', 'ndim_m1', 'shape_m1[*]',
-                          'strides[*]', 'backstrides[*]', 'indices']
+                          'strides[*]', 'backstrides[*]']
 
     def __init__(self, array, size, shape, strides, backstrides):
         assert len(shape) == len(strides) == len(backstrides)
@@ -90,17 +90,13 @@
         self.shape_m1 = [s - 1 for s in shape]
         self.strides = strides
         self.backstrides = backstrides
-        self.indices = [0] * len(shape)
         self.reset()
 
-    @jit.unroll_safe
     def reset(self):
         self.index = 0
-        for i in xrange(self.ndim_m1, -1, -1):
-            self.indices[i] = 0
+        self.indices = [0] * len(self.shape_m1)
         self.offset = self.array.start
 
-    @jit.unroll_safe
     def next(self):
         self.index += 1
         for i in xrange(self.ndim_m1, -1, -1):
@@ -112,7 +108,6 @@
                 self.indices[i] = 0
                 self.offset -= self.backstrides[i]
 
-    @jit.unroll_safe
     def next_skip_x(self, step):
         assert step >= 0
         if step == 0:
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
@@ -167,7 +167,6 @@
         # check that we got only one loop
         assert len(get_stats().loops) == 1
 
-
     def define_prod():
         return """
         a = |30|
@@ -429,6 +428,7 @@
                                 'raw_store': 1, 'int_add': 1,
                                 'int_ge': 1, 'guard_false': 1, 'jump': 1,
                                 'arraylen_gc': 1})
+
     def define_flat_iter():
         return '''
         a = |30|
@@ -517,29 +517,29 @@
                                 'int_lt': 1,
                                 'jump': 1,
                                 'raw_load': 2})
-        self.check_resops({'float_add': 2,
+        self.check_resops({'arraylen_gc': 1,
+                           'call': 3,
+                           'float_add': 2,
                            'float_mul': 2,
-                           'getarrayitem_gc': 11,
-                           'getarrayitem_gc_pure': 15,
-                           'getfield_gc': 30,
-                           'getfield_gc_pure': 44,
+                           'getfield_gc': 26,
+                           'getfield_gc_pure': 24,
                            'guard_class': 4,
-                           'guard_false': 14,
+                           'guard_false': 2,
+                           'guard_no_exception': 3,
                            'guard_nonnull': 8,
                            'guard_nonnull_class': 4,
                            'guard_not_invalidated': 2,
-                           'guard_true': 13,
+                           'guard_true': 9,
                            'guard_value': 4,
-                           'int_add': 25,
-                           'int_ge': 4,
-                           'int_le': 8,
-                           'int_lt': 11,
-                           'int_sub': 4,
+                           'int_add': 6,
+                           'int_force_ge_zero': 1,
+                           'int_ge': 3,
+                           'int_lt': 4,
                            'jump': 3,
+                           'new_array': 1,
                            'raw_load': 6,
                            'raw_store': 1,
-                           'setarrayitem_gc': 10,
-                           'setfield_gc': 14})
+                           'setfield_gc': 3})
 
     def define_argsort():
         return """
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to