We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

FAT Python: a new static optimizer for Python 3.6

Formal Metadata

Title
FAT Python: a new static optimizer for Python 3.6
Title of Series
Part Number
64
Number of Parts
169
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date2016
LanguageEnglish

Content Metadata

Subject Area
Genre
Abstract
Victor Stinner - FAT Python: a new static optimizer for Python 3.6 The Python language is hard to optimize. Let's see how guards checked at runtime allows to implement new optimizations without breaking the Python semantic. ----- (Almost) everything in Python is mutable which makes Python a language very difficult to optimize. Most optimizations rely on assumptions, for example that builtin functions are not replaced. Optimizing Python requires a trigger to disable optimization when an assumption is no more true. FAT Python exactly does that with guards checked at runtime. For example, an optimization relying on the builtin len function is disabled when the function is replaced. Guards allows to implement various optimizations. Examples: loop unrolling (duplicate the loop body), constant folding (propagates constants), copy builtins to constants, remove unused local variables, etc. FAT Python implements guards and an optimizer rewriting the Abstract Syntax Tree (AST). The optimizer is implemented in Python so it's easy to enhance it and implement new optimizations. FAT Python uses a static optimizer, it is less powerful than a JIT compiler like PyPy with tracing, but it was written to be integrated into CPython. I wrote 3 PEP (509, 510, 511) targeting Python 3.6. Some changes to support FAT Python have already been merged into Python 3.6. We will also see other pending patches to optimize CPython core, and the bytecode project which allows to modify bytecode, it also includes a peephole optimizer written in pure Python.