Pedal to the metal: PyPy 2.4 powers up Python

JIT-powered Python engine PyPy was already fast, but version 2.4 charges further ahead, thanks to multithreaded optimizations

pypy logo

Pythonistas wince when they hear the truism about Python being fast to develop in but slow to actually run. The newest iteration of an alternative Python interpreter aims to prove that wrong.

PyPy, an implementation of Python 2, has long been one of the projects designed to give Python a speed boost via its JIT (just in time) compiler. Under PyPy, many Python programs run an average of six times faster than with the stock Python interpreter.

"Snow White," per PyPy 2.4's code name, offers internal fixes and speed improvements over previous editions. For one, it uses Python's 2.7.8 standard library, where the previous version of PyPy only supported up to version 2.7.5. The Windows version of PyPy has also been cleaned up to be statically linked to many common libraries to address Windows users' complaints about missing DLLs.

Most of the performance improvements are due to a few key tweaks to the way JITing works. PyPy now uses what's described as a "mixed polling and mutex GIL (global interpreter lock) model" to improve the speed of multithreaded code and to speed up the handling of calls to external libraries.

pypy speed

PyPy can provide speed improvements of up to an order of magnitude over the stock implementation of Python.

The GIL has been a perennial roadblock to improving Python performance. It serializes access to Python's interpreter by multiple threads and thus works as a gateway to the likes of high-performance C extensions. Some implementations of Python, such as the JVM-based Jython or the .Net-based IronPython, aren't saddled with a GIL. As a trade-off, those interpreters can't make use of C extensions. (C extensions work in PyPy, but not as-is; they have to be recompiled.)

The biggest drawback to using PyPy echoes the most divisive rift within the Python community: Right now, PyPy can't support Python 3. That said, a project is in the works to enable Python 3 support in PyPy, but it's a ways from being finished. Likewise, the Pyston project, which aims to use the LLVM compiler framework to compile Python to machine language, is targeting only Python 2.7 at this time.

From CIO: 8 Free Online Courses to Grow Your Tech Skills