[pypy-issue] [issue1707] speed regression on simple numpy loop

mattip tracker at bugs.pypy.org
Tue Mar 11 22:49:12 CET 2014


New submission from mattip <matti.picus at gmail.com>:

As reported on the pypy/numpy repo issue tracker, looping over a numpy ndarray 
has taken a big hit. The original report was for Linux, here I am testing Win32
D:\pypy_stuff>pypy-c-jit-68585-0dcf482a5cb8-win32\pypy.exe c:\temp\test_pypy.py
total 500
total 500
total 500
total 500
total 500
total 500
total 500
total 500
total 500
[2.5512983611464493, 2.32676067179098, 2.320774419773148]

D:\pypy_stuff>pypy-c-jit-69845-3eb83f4075a3-win32\pypy.exe c:\temp\test_pypy.py
total 500
total 500
total 500
total 500
total 500
total 500
total 500
total 500
total 500
[64.27379266845556, 64.29791385595621, 64.82441196908306]

----------
files: test_pypy.py
messages: 6591
nosy: bdk, mattip, pypy-issue
priority: performance bug
status: chatting
title: speed regression on simple numpy loop

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1707>
________________________________________
-------------- next part --------------

try:
    import numpy as np
except ImportError:
    import _numpypy.multiarray as np

tiles = np.zeros((256, 256), 'uint8')  # also tried uint32 - same result
tiles[5, 5] = 1

def benchmark_raw():
    total = 0
    for _ in xrange(500):
        for x in xrange(256):
            for y in xrange(256):
                total += tiles[x, y]
    print 'total',total

if __name__ == "__main__":
    import timeit
    t = timeit.Timer("benchmark_raw()", setup="from __main__ import benchmark_raw")
    times = t.repeat(repeat=3, number = 3)
    print times


More information about the pypy-issue mailing list