Run your Python application using PyPy – it’s fast!

Try your Python application with PyPy, the new hot Python JIT compiler

  • Your program will run faster…
  • … faster…
  • and ..faster!

Here are quick instructions for using PyPy on OSX. You should be able to apply these instructions to other UNIX systems as well.

Install PyPy by getting binary tarball.

tar -xjf

Install Distribute / easy_install command (setuptools fork) in order to install third party libraries.

cd pypy-1.4.1-osx64

Install libraries – easy_install seems to run just fine on PyPy as long as you don’t try to install Python native extensions

bin/easy_install plac # command line parser
bin/easy_install iso8601 # date format parser

Then run your application

~/code/pypy-1.4.1-osx64/bin/pypy     -s=2010-01-01T00:00:00 /Users/moo/xxx/log/client1.log

In my case the application was a simple log analyzer based on Python generators (code will be posted later). It reads a text file and tries to interpret it. The script utilizes only one CPU core and thus is very CPU bound. The speed comparison results are

  • With Python 2.4: Completed in 111.08 seconds
  • With PyPy: Completed in 30.39 seconds

That’s almost 4x speed-up!

Things did not work with PyPy

  • import multiprocessing – was not hard dependency, needed to comment out in plac_ext

Here is the traceback if anyone can help:

Traceback (most recent call last):
 File "", line 53, in run_toplevel
 File "", line 20, in <module>
 import plac
 File "/Users/moo/code/pypy-1.4.1-osx64/site-packages/plac-0.8.0-py2.5.egg/", line 35, in <module>
 from plac_ext import Interpreter, import_main, ReadlineInput, stdout, runp, Monitor
 File "/Users/moo/code/pypy-1.4.1-osx64/site-packages/plac-0.8.0-py2.5.egg/", line 7, in <module>
 import itertools, traceback, multiprocessing, signal, threading
 File "/Users/moo/code/pypy-1.4.1-osx64/site-packages/multiprocessing-", line 87, in <module>
 import _multiprocessing
 File "/Users/moo/code/pypy-1.4.1-osx64/site-packages/multiprocessing-", line 7, in <module>
 File "/Users/moo/code/pypy-1.4.1-osx64/site-packages/multiprocessing-", line 6, in __bootstrap__
AttributeError: 'module' object has no attribute 'load_dynamic'

\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

6 thoughts on “Run your Python application using PyPy – it’s fast!

  1. The external multiprocessing lib is a C extension and so we wouldn’t expect it to work. However, starting in Python 2.6 it is part of the standard library and thus will be a part of the next PyPy release, which implements Python 2.7, and will be out as soon as we finish the last few bugs.

  2. Regarding multiprocessing, you should download a nightly, where it’s a built-in module. If there are none available for OSX64, try translating it yourself. It should also be faster in general:

  3. the nightly builds include support for python2.7, you might want to try those

  4. hi, can i use pypy on windows 7?
    right now im using python 2.6.7…i ve already written code using it..
    i just need to make the prog run fast…
    how can i do that.?
    please help

Leave a Reply

Your email address will not be published. Required fields are marked *