[Python-ideas] Disable all peephole optimizations

Paul Moore p.f.moore at gmail.com
Wed May 21 15:05:07 CEST 2014


On 21 May 2014 12:05, Ned Batchelder <ned at nedbatchelder.com> wrote:
> Unfortunately, the -O command-line switch does not lend itself to a new
> value that means, "less optimization than the default."  I propose a new
> switch -P, to control the peephole optimizer, with a value of -P0 meaning no
> optimization at all.  The PYTHONPEEPHOLE environment variable would also
> control the option.

The idea sounds reasonable (pretty specialised, but that's OK). But
one pitfall is that unless you encode the PYTHONPEEPHOLE setting in
the bytecode filename then people will have to remember to delete all
bytecode files before using the flag, or the interpreter will pick up
an optimised pyc file. Or maybe pyc/pyo files should be ignored if
PYTHONPEEPHOLE is set? That's probably simpler.

Paul


More information about the Python-ideas mailing list