PyPy 7 speeds up Python 2.7, Python 3.5, and Python 3.6 alike
- 12 February, 2019 05:13
PyPy, the Python runtime that uses just-in-time compilation to achieve major performance improvements over the stock CPython distribution, is now available in version 7.0 releases supporting Python 2.7, Python 3.5, and Python 3.6.
According to a post on the official PyPy Status Blog, all three versions use “much the same codebase, thus the triple release.” The Python 3.6 interpreter is “the first official release of PyPy to support Python 3.6 features, although it is still considered alpha quality.” Most of the improvements to PyPy over the last release involve memory management and interfacing with external C code built for Python.
CPython provides programmatic hooks into its garbage collection subsystem. PyPy 7 goes a step further, running the garbage collector in incremental steps to prevent the garbage collection process from bringing programs to a halt for too long.
One longstanding issue with PyPy versus the stock CPython interpreter is that many packages that use binary wheels, or binary components built to run with the Python interpreter, may not work correctly or at the same speed. Officially, any C/C++ projects that need to work with PyPy should use the
cppyy projects to wrap their binaries. The latest versions of these projects now work with PyPy.
Third parties also offer rebuilds of some popular Python packages, such as NumPy, Pandas, and SciPy, to work specifically with PyPy, but that build process is still experimental and yields binaries only for Ubuntu Linux.
Many of the other changes and improvements in PyPy 7 involve better support for async structures and compatibility with other language features in Python 3.5 and Python 3.6. However, PyPy’s creators advise that the release for Python 3.6, as well as for Python 3.5 for Windows, is “still not production quality” as “there are open issues with incomplete compatibility and C extension support.”
PyPy’s development has yielded benefits for the main CPython project as well. When PyPy’s developers rewrote the code for handling Python’s dictionary data structure to improve performance and save memory, CPython adopted that code as well. PyPy’s garbage collection features, such as the step-at-a-time collection system, would be useful in CPython too, but the fundamentally different ways the two runtimes handle garbage collection might make that hard to pull off.