PyPy 5.1 puts Python's pedal to the metal

The optimizing compiler features powerful performance improvements, but the default version of Python has its own speed tricks slated for version 3.6

PyPy 5.1 puts Python's pedal to the metal
Frankie Leon (Creative Commons BY or BY-SA)

PyPy, the just-in-time optimizing compiler for Python, has been updated to 5.1, boasting even faster startup and optimization times.

But CPython, the default Python interpreter written in C, is also getting optimizations. They aren't likely anywhere near as dramatic as PyPy's, but they'll satisfy a larger set of use cases.

When PyPy 5.0 was released earlier this year, it featured a faster startup time for the interpreter, which was a major issue for PyPy. Smaller scripts that started running almost immediately on CPython took a far longer time to launch with PyPy, obliterating the performance gains from compiling the script in the first place.

PyPy 5.1 improves even further on its predecessors. According to benchmarks published by the PyPy team earlier this month, the overall warmup bechmarks are now 90 percent faster than the pre-5.0 branch. "We have more optimizations in the pipeline," writes the team, "with an idea how to transfer some of the JIT gains into more of a total program runtime by jitting earlier and more eagerly."

Also, PyPy 5.1 adds back-end assembler support for IBM z/Architecture machines running Linux. PyPy already supports a broad variety of CPU architectures -- 32- and 64-bit flavors of x86, 32-bit ARM, and PowerPC 64-bit -- so this isn't unprecedented for PyPy. It also falls in line with the way various late-model languages have been adding z System support, such as Google's Go language.

But CPython isn't resting on its performance laurels, thanks to optimizations in Python 3.6. The FAT Python project speeds up script execution by minimizing checks to see whether dictionary objects were modified. Another recently introduced optimization, wordcode, changes Python's bytecode format so that more instructions and data can be fetched in a single operation. Yet another small change is expected to speed up method calls by 20 percent.

None of these improvements will yield the drastic, orders-of-magnitude performance improvements produced by PyPy. But CPython provides a reference implementation of the language, even if it isn't the fastest, and is as broadly compatible with existing Python applications as possible.

By contrast, PyPy's speed comes at the cost of universal compatibility. It has issues with some Python applications that use the CPython C API, and C extensions need to be recompiled for use with PyPy.

Copyright © 2016 IDG Communications, Inc.

How to choose a low-code development platform