PyPy: Making Python faster?

PyPy is really interesting - they are implementing Python in Python! This may sound absurd, but it is quite common for computer languages to reimplement themselves.

I stumbled over this reddit comment. It has following code that shows that PyPy may boost Python's performance to new levels:

$ python translatorshell.py
>>> def ack(x,y):
      if x == 0: return y + 1
      elif y == 0: return ack(x - 1, 1)
      else: return ack(x - 1, ack(x, y - 1))
>>> t = Translation(ack)
>>> t.annotate([int, int])
>>> t.rtype()
>>> ack_c = t.compile_c()
>>> import time
>>> start = time.time(); ack(3,6); print time.time() - start
509
0.19878911972
>>> start = time.time(); ack_c(3,6); print time.time() - start
509
0.00290894508362

Very interesting!

Code · Python 24. Feb 2007
© Amir Salihefendic. Powered by Skeletonz.