Skip to content

Python Warp 9 – PyPy Beta For Raspberry Pi

by on July 11, 2013

raspberry-pi-revision-2

Back in May, the Raspberry Pi Foundation mentioned that they had been sponsoring the development of the ARM port of PyPy, the high-performance Python interpreter. The team released a first beta of the upcoming 2.1 release, which for the first time adds ARM as an officially supported architecture.

You can see the announcement here, and download binaries for Raspbian here. Give it a spin and let us know what you think.

The tests below are run on a basic Raspberry Pi Model B Revision 1 with 700MHz CPU and 256MB RAM.

Stock Python 2.7.3 Raspbian

Below are two simple tests, for demonstrating the basic performance of some simple string manipulation:
pi@raspberrypi ~ $ python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> import string
>>> def doit1():
... string.lower('TEST Test test')
...
>>> t = timeit.Timer(setup='from __main__ import doit1', stmt='doit1()')
>>> t.timeit()
12.213012218475342
>>> def doit2():
... import string
... string.lower('TEST Test test')
...
>>> t = timeit.Timer(setup='from __main__ import doit2', stmt='doit2()')
>>> t.timeit()
41.242599964141846

Thats an astonishing 12.2 and 41.2 seconds!

It felt really slow on my Pi, it felt like I was waiting for a long time, for such a simple operation 😦

PyPy 2.1.0 Beta Raspbian

Now exactly the same test performed on the Hardfloat compiled beta edition of PyPy:
pi@raspberrypi ~/pypy-2.1-beta-linux-armhf-raspbian $ ./bin/pypy
Python 2.7.3 (daf1b0412bfb, Jul 10 2013, 15:24:09)
[PyPy 2.1.0-beta1 with GCC 4.7.2 20120731 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``happy new year''
>>>> import timeit
>>>> import string
>>>> def doit1():
.... string.lower('TEST Test test')
....
>>>> t = timeit.Timer(setup='from __main__ import doit1', stmt='doit1()')
>>>> t.timeit()
0.19308209419250488
>>>> def doit2():
.... import string
.... string.lower('TEST Test test')
....
>>>> t = timeit.Timer(setup='from __main__ import doit2', stmt='doit2()')
>>>> t.timeit()
0.23908400535583496

GREAT Scott that’s 0.19 and 0.23 seconds!!!

The results were on the screen within a blink of an eye!

This speed up is definitely going to get me to start developing more scripts in Python on the Pi!!!

I see this as an additional improvement to the development of the Pineapple Pi.

From → Python, Raspberry Pi

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: