[pypy-dev] Updated 'High Performance Python' tutorial (the one from EuroPython 2011)

Maciej Fijalkowski fijall at gmail.com
Mon Jul 25 11:08:12 CEST 2011


On Mon, Jul 25, 2011 at 11:00 AM, Ian Ozsvald <ian at ianozsvald.com> wrote:
> Dear all, I've published v0.2 of my High Performance Python tutorial
> write-up from the session I ran at EuroPython:
> http://ianozsvald.com/2011/07/25/high-performance-python-tutorial-v0-2-from-europython-2011/
>
> Antonio - you asked earlier if the 'expanded math' version of the
> Mandelbrot solver (using doubles rather than complex numbers) would be
> faster - I've timed it and it is a bit faster with a nightly build of
> PyPy, but nowhere near as fast at ShedSkin's generated C output
> (details below).
>
> Maciej - thanks for pointing me at the numpy module. I've added a tiny
> section showing numpy in PyPy but I haven't converted the Mandelbrot
> solver to use it (even finishing v0.2 took longer than I'd thought).
> I'm hoping that some more exposure in the report might bring in more
> volunteers from outside.
>
> Here's a clip from the report in the PyPy section:
> "By running pypy pure_python.py 1000 1000 on my MacBook it takes 5.9
> seconds, running pypy pure_python_2.py 1000 1000 takes 4.9 seconds.
> (Ian - the only difference with pure_python_2.py is that local
> dereferences in the tight loop are moved outside the loop, causing
> fewer dereference operations)
>
> As an additional test (not shown in the graphs) I ran pypy
> shedskin2.py 1000 1000 which runs the expanded math version of the
> shedskin variant below (this replaces complex numbers with floats and
> expands abs to avoid the square root). The shedskin2.py result takes
> 3.2 seconds (which is still much slower than the 0.4s version compiled
> using shedskin)."
>
> The pure_python src is here:
> https://github.com/ianozsvald/EuroPython2011_HighPerformanceComputing/tree/master/mandelbrot/python
>
> shedskin2.py is available here:
> https://github.com/ianozsvald/EuroPython2011_HighPerformanceComputing/tree/master/mandelbrot/shedskin
>
> I haven't tested whether the warm-up periods for PyPy are significant,
> possibly they account for much of the difference between ShedSkin and
> PyPy? I want to revisit this but for the next few weeks I have to go
> back to other projects.

Most come from the fact that you're using lists and not say
array.array (or numpy array), so the storage is not optimized.
ShedSkin doesn't allow you to store different types in a list. We'll
make it fast one day even if you use list, but indeed, using
array.array would make it much faster.

Cheers,
fijal


More information about the pypy-dev mailing list