Python bytecode

CPython peephole optimizer

Implementation: Python/peephole.c


Latest enhancement:

changeset:   68375:14205d0fee45
user:        Antoine Pitrou <>
date:        Fri Mar 11 17:27:02 2011 +0100
files:       Lib/test/ Misc/NEWS Python/peephole.c
Issue #11244: The peephole optimizer is now able to constant-fold
arbitrarily complex expressions.  This also fixes a 3.2 regression where
operations involving negative numbers were not constant-folded.

Compiler enhancement to reduce the number of stupid jumps:

changeset:   92460:c0ca9d32aed4
user:        Antoine Pitrou <>
date:        Thu Sep 18 03:06:50 2014 +0200
files:       Lib/test/ Misc/NEWS Python/compile.c
Closes #11471: avoid generating a JUMP_FORWARD instruction at the end
of an if-block if there is no else-clause.

Original patch by Eugene Toder.

Should be rewritten as an AST optimizer.