'FAT' and fast: What's next for Python

A proposed set of changes to Python's stock interpreter will speed up execution of the language without the use of a compiler

 'FAT' and fast: What's next for Python
Credit: Danleo

The FAT Python project, spearheaded by core Python contributor Victor Stinner, is investigating optimizations that can be added directly to the Python interpreter without breaking compatibility with existing applications.

Most speed optimizations for Python, such as the PyPy variant of the interpreter, involve adding a JIT (just-in-time) compiler. FAT Python instead optimizes behaviors of the reference implementation of Python, CPython.

Originally described on the python-dev mailing list in November 2015, the project has since been through a few milestones. The most recent adds optimizations seen in compilers used for other languages, such as loop unrolling and constant folding, and the changes proposed pass the vast majority of Python's own test suite.

"Python is hard to optimize because everything is mutable," writes Stinner in a draft version of one of his proposals for the project, so the optimizations he's considering must take that into account. For instance, one change postulated is using a constant to speed up the process and to test efficiently if the needed object has been modified or not.

Another proposal, also a draft, involves creating an API to transform Python's ASTs (Abstract Syntax Trees), the mechanism by which Python code can be inspected and modified at a high level. An API for AST transformers, proposes Stinner, would make it easier to optimize Python in the long run.

Python's reputation for being easy to develop in and having a massive ecosystem of first- and third-party libraries have overshadowed its performance limitations. But competition is mounting from other languages -- Google's Go, Apple's newly open-sourced Swift, and JavaScript -- that balance speed of development against speed of execution. Still, Python won't likely be displaced based on performance alone, as its popularity continues to rise as both a teaching and general development language.

From CIO: 8 Free Online Courses to Grow Your Tech Skills
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies