<div dir="ltr">I am trying to understand why is so difficult to implement fast compilers for languages like Python and Ruby. In particular, I wrote a few programs in Racket, SBCL, and Python (PyPy). Most of these benchmarks deal with number crunching (like simplex method and solving linear equations), list processing (like genetic programming), text processing (like text editors and dictionary generation), and electronic CAD (like Quine McCluskey solver). The final result is that Racket is at least ten times faster than PyPy. For instance, a Python simplex solver takes 87 seconds to solve a system of 1000 inequalities in PyPy. After translating this very same solver to Racket, it takes about 10 seconds. I am running the programs in a MacMini, I7, 64 bits. PyPy version 2.3, and Racket version 6.0.1. <div>
<br></div><div>I understand that PyPy has a JIT compiler, and so does Racket. I also suppose that the authors of PyPy know what they are doing. Therefore, the two languages should be equally fast. Why Racket is much faster than PyPy? By the way, SBCL (a Lisp implementation) is much faster than PyPy too.</div>
<div><br></div><div>Is there anything in the semantic of Python that makes it much more difficult to implement a Python compiler than a Racket compiler? I read somewhere that Python does not have tail call optimisation because its definition requires preservation of the stack. Besides this, one cannot modify a Python closure. Lists in Python must be defined as vectors. People say that all this makes a Python compiler hard to implement. I hope that members of this list could tell me what feature of Racket made it possible the construction of a compiler that generates fast code. </div>
<div> </div></div>