Author: Brian Kearns <[email protected]>
Branch:
Changeset: r70669:4b3a31de60d3
Date: 2014-04-16 18:22 -0400
http://bitbucket.org/pypy/pypy/changeset/4b3a31de60d3/
Log: eliminate duplicate getarrayitem_gc in numpy iterator next
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
@@ -101,8 +101,9 @@
def next(self):
self.index += 1
for i in xrange(self.ndim_m1, -1, -1):
- if self.indices[i] < self.shape_m1[i]:
- self.indices[i] += 1
+ idx = self.indices[i]
+ if idx < self.shape_m1[i]:
+ self.indices[i] = idx + 1
self.offset += self.strides[i]
break
else:
@@ -116,8 +117,9 @@
return
self.index += step
for i in xrange(self.ndim_m1, -1, -1):
- if self.indices[i] < (self.shape_m1[i] + 1) - step:
- self.indices[i] += step
+ idx = self.indices[i]
+ if idx < (self.shape_m1[i] + 1) - step:
+ self.indices[i] = idx + step
self.offset += self.strides[i] * step
break
else:
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
@@ -482,7 +482,7 @@
assert result == 1.0
self.check_trace_count(1)
self.check_simple_loop({
- 'getarrayitem_gc': 4,
+ 'getarrayitem_gc': 2,
'getfield_gc': 4,
'guard_not_invalidated': 1,
'guard_true': 3,
@@ -523,7 +523,7 @@
'arraylen_gc': 1,
'float_add': 2,
'float_mul': 2,
- 'getarrayitem_gc': 11,
+ 'getarrayitem_gc': 7,
'getarrayitem_gc_pure': 15,
'getfield_gc': 35,
'getfield_gc_pure': 39,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit