Am I using PyPy wrong? It's slower 10x than standard Python


I have heard good stuff about PyPy. In particular I'd heard that it was very fast which made me wonder if it might be usable for an embedded project I have.

I downloaded PyPy-2.6 for my Windows 7 PC, and unzipped the contents into a directory.

I've written a small test program to allow me to benchmark:

import time def fib(n): if n == 0 or n == 1: return 1 return fib(n - 1) + fib(n - 2) t0 = time.time() fib(20) t1 = time.time() print t1-t0

So I went to the directory where PyPy was unzipped, ran ./pypy.exe hello.py and got an answer of 0.120.

Then I fired up a cygwin console and ran python hello.py and got an answer of 0.01.

Am I using PyPy wrong or is it only faster for certain applications?


Thanks to Rob who pointed out that the JIT compiler needs time to warm up.

Extending my sample code produces the following results:

n PyPy Python 20 0.12 0.01 25 0.15 0.06 30 0.34 0.67 35 0.92 7.39 40 10.98 82.9

It seems like there's a 0.1 second start-up cost or something, but after that it's faster.


It is only faster for certain applications. Quoting the <a href="http://pypy.org/features.html" rel="nofollow">PyPy doc</a>:


There are two cases that you should be aware where PyPy will not be able to speed up your code:


Short-running processes: if it doesn't run for at least a few seconds, then the JIT compiler won't have enough time to warm up.

</li> <li>

If all the time is spent in run-time libraries (i.e. in C functions), and not actually running Python code, the JIT compiler will not help.

</li> </ul></blockquote>

Since your program seems to run on the order of 10<sup><sup>-</sup>2</sup> or 10<sup><sup>-</sup>1</sup> seconds, the JIT compiler doesn't do you any good.


  • 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'forEach&
  • Xcode google map navigation
  • ADO.NET Data Services Entity Framework request error when property setter is internal
  • QT QSslError being signaled with the error code set to NoError
  • All possible combinations of card/poker hands for a set of players
  • Can a filter access properties from my BaseController?
  • Visual Studio Code starting from command line batch prints out “update#setState” every hour
  • Is it possible to disable authentication Filter on one action in an MVC 5 controller?
  • Adjacent svg:polygon edges do not meet
  • Visual Studio 2012 C++ compile error with Boost Signal2
  • How to pause using DownloadManager?
  • making an array of bigInteger of size biginteger in java
  • Firebase Database OutofMemory Error
  • How to add an Auth Token in every request using AFIncrementalStore?
  • playing mp3 from nsbundle
  • xpath assertion failure with dynamic xpath
  • how to run a different select statement based on condition in Hive SQL
  • LinkedIn API: Access Denied when getting Access Token
  • Google App Engine backend servlet not responding
  • Make checkout phone field optional for specific countries in WooCommerce
  • Excel VBA : conditional formatting of sheet1 cells from sheet2 values in excel 2007
  • Cross compile glibc for arm, got undefined reference to some unwind functions
  • How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?
  • Firebase: How to read from external DB?
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication
  • convert json to excel in java
  • JavaScript RegExp Replace