So, in order to make up for lost time, I’ve been coding a significant amount the past 48 hours, near non-stop. My labor has finally bore fruit.
Micronumpy found at https://codespeak.net/svn/pypy/branch (Click to browse the source, copy the link name for the checkout address, full instructions here) has been rewritten to use
lltype.Array and now supports enough to run the convolve benchmark found in pypy/tool/numpybenchmark.py which is a slightly modified version of this. Unfortunately, pypy segfaults if the test is run more than 20 times by timeit. However, with 20 repetitions, a 200 by 200 image, and a 3×3 kernel, PyPy handily beats CPython and plain NumPy.
|Command||Average Time per run (Seconds)|
|./pypy-c ~/Projects/micronumpy/pypy/tool/numpybench.py 200 200 3 3||0.38495|
|python ~/Projects/micronumpy/pypy/tool/numpybench.py 200 200 3 3||0.85705|
That’s an improvement of about 55% shorter runtime!
That’s not bad for a first iteration (Even if the iteration’s been a while in the works). Now note that the benchmark as it is right now does not provide for a warmup period, which should improve PyPy’s score even more. Whether or not a warmup period is more or less of a measurement of what we care about, I’m not sure. Also note that, while the times have remained stable, they are likely susceptible to my other processes on this computer. I plan on writing a follow up article which will hopefully have more interesting results, and maybe even a graph!
NumPy on PyPy
Though it’s taken far longer than any of us expected(Except maybe Maciej). I’m very hopeful that in the next week or so I can have NumPy running in a somewhat stable fashion on PyPy. Currently I’m hacking on
lltype to give more useful
str() values, rather than
<* <Array of Char> at 0xDEADBEEF> I hope it will look more like
<* <Char array = "spam"> at 0xDEADBEEF> which I think will be a useful debugging tool for everyone.
More on everything after the midterm reviews :-)