[pypy-commit] pypy default: avoid new array in iter reset
bdkearns
noreply at buildbot.pypy.org
Fri Apr 18 00:08:45 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r70718:5276d89f1cca
Date: 2014-04-17 15:08 -0400
http://bitbucket.org/pypy/pypy/changeset/5276d89f1cca/
Log: avoid new array in iter reset
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
@@ -90,11 +90,16 @@
self.shape_m1 = [s - 1 for s in shape]
self.strides = strides
self.backstrides = backstrides
- self.reset()
+ self.index = 0
+ self.indices = [0] * len(shape)
+ self.offset = array.start
+
+ @jit.unroll_safe
def reset(self):
self.index = 0
- self.indices = [0] * len(self.shape_m1)
+ for i in xrange(self.ndim_m1, -1, -1):
+ self.indices[i] = 0
self.offset = self.array.start
@jit.unroll_safe
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
@@ -564,7 +564,6 @@
'raw_load': 2,
})
self.check_resops({
- 'arraylen_gc': 1,
'float_add': 2,
'float_mul': 2,
'getarrayitem_gc': 7,
@@ -584,11 +583,10 @@
'int_lt': 11,
'int_sub': 4,
'jump': 3,
- 'new_array': 1,
'raw_load': 6,
'raw_store': 1,
- 'setarrayitem_gc': 8,
- 'setfield_gc': 15,
+ 'setarrayitem_gc': 10,
+ 'setfield_gc': 14,
})
def define_argsort():
More information about the pypy-commit
mailing list