Victor Stinner - FAT Python: a new static optimizer for Python 3.6

Published: 01 August 2016
on channel: EuroPython Conference
2,432
19

Victor Stinner - FAT Python: a new static optimizer for Python 3.6
[EuroPython 2016]
[20 July 2016]
[Bilbao, Euskadi, Spain]
(https://ep2016.europython.eu//confere...)

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.

Links:

http://faster-cpython.readthedocs.org...
http://fatoptimizer.readthedocs.org/
http://bytecode.readthedocs.org/


Watch video Victor Stinner - FAT Python: a new static optimizer for Python 3.6 online without registration, duration hours minute second in high quality. This video was added by user EuroPython Conference 01 August 2016, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,43 once and liked it 1 people.