Python crunches numbers faster with PyPy 4.0

Python's optimizing compiler adds support for SIMD instructions to accelerate math, in the first of several major-league performance boosts

Python crunches numbers faster with PyPy 4.0 (Creative Commons BY or BY-SA)

PyPy, the Python compiler that boasts a massive speed improvement over the stock CPython interpreter, has reached a major milestone with version 4.0.

The biggest new feature in PyPy 4 (aside from the version-numbering scheme) is a vectorizing optimizer. This addition to the compiler, courtesy of a Google Summer of Code project, allows it to speed up operations via the SIMD instruction sets available in modern processors.

Since vectorization is a work in progress for PyPy, it's available in 4.0 in only a preliminary form and is turned off by default; the user has to manually enable it through a command-line flag. Also, the scope of the improvements right now is limited to math functions, such as vector and matrix manipulations, or operations performed through the NumPy library.

According to PyPy's developers, the speed gained from vectorization, even early on, is impressive -- anywhere between two and four times what CPython (for Python 2.7.10) delivers. Many other improvements are under consideration for future versions, such as changes to memory throughput on the CPU or finding ways to enable vectorization globally throughout the compiler.

Other updates to PyPy include better NumPy support (both as part of the vectorization process and apart from it), a 20 percent jump in startup time, and new features for the Python C Foreign Function Interface (CFFI) project. The last one allows Python to call C code, either in the form of accessing precompiled modules or by having C code listed in-line with Python code.

One major goal still not met with PyPy is support for Python 3, aka the py3k project. PyPy's developers have been soliciting money for the project in a budget separate from PyPy itself, but there has been little public word about py3k since 2014.

Another major compiler project in the Python ecosystem, Nuitka, had its own milestones earlier this month. Nuitka, which compiles Python 2.x and 3.x to binaries, recently added support for static single assignment (SSA), an optimization that paves the way toward other and substantive performance increases.

Copyright © 2015 IDG Communications, Inc.