How to do it...

  1. To run PyPy, simply go to the location where you placed the binary and call PyPy:

As can be seen, it looks like a standard Python interactive interpreter, so you can experiment with your code as normal.

  1. For a simple test to demonstrate how quick PyPy compares with normal Python, we will make a couple of files, as well as a C file, to see how well PyPy's JIT compiler compares:
    • We save the following as add_funct.py:
                 def add(x, y):                      return x + y 
    • The following is loop_funct.py:
                  from file1 import add                      def loop():                          i = 0                          a = 0.0                          while i < 1000000000:                                  a += 1.0                              add(a, a)                              i += 1                      if __name__ == "__main__":                          loop() 

Get Secret Recipes of the Python Ninja now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.