PyPy 1.2 came out and accelerated Python at times!

Published on March 12, 2010

PyPy 1.2 came out and accelerated Python at times!

    I came PyPy 1.2. The main difference is the presence of a JIT compiler .
    In order not to explain for a long time what it is and why - a simple test:

    cnt = 10 * 1000 * 1000
    for _ in xrange (cnt): 
        i = i + 1


    5.8mln operations per second on regular Сython 2.6 ( python test.py)
    42.5mln operations per second on PyPy 1.2 ( pypy test.py)
    WinXP SP3, Core2Duo.

    Yes, 7 times faster he did the test! And this is not only on the synthetic test: “django” is 3 times faster, “n-body” is 7 times faster ... I don’t know what the “richards” test is, but now it is almost 12 times faster. See the results yourself .

    Read and download (from the "JIT compiler" version "section). There is no 64-bit version yet. And unladen-swallow nervously smokes ... Under the cut some more improbability (stackless, "sandbox for python code") ..

    There is also a stackless version in their archives ... and most importantly, a sandbox version! This is the version that solves Python’s long-standing problem - the lack of a safe environment for executing code that we don’t trust. External code in C will not even allow you to do os.listdir('/')it if I correctly understood the hint of the authors. It sways in the same place as the usual one.

    Personally, I generally looked at PyPy as a strange experiment - Python, and so to say, is super-fast, and writing its interpreter in Python itself seemed just perverted by the amusement of the authors ... However, with the introduction of JIT, it became something incredible in speed.

    The authors say that in this version there are no crashes, but nevertheless they ask to treat this version as a beta anyway.

    In addition, the authors warn that because of the use of JIT, it is still difficult to control the amount of memory that this Python eats. But here, in essence, “speed-memory tradeoff” in its pure form is obtained.

    For me, as a big fan of Python, and for the language as a whole, this is just a real breakthrough. Now I will closely monitor their development. Of course, there are tests in it that CPython wins, but there are significantly fewer than those that it loses. And the gain is not just 10-20% there, but 3x, 5x, 8x times! In general, it sounds incredible, but the guys from PyPy invented V8 but for Python.

    How to use?

    Download , unzip, instead of python ваш-скрипт.pylaunching pypy ваш-скрипт.py

    Yoi Haji,
    view from Habr