[Python-ideas] Disable all peephole optimizations
Ned Batchelder
ned at nedbatchelder.com
Wed May 21 16:13:57 CEST 2014
On 5/21/14 9:05 AM, Paul Moore wrote:
> 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.
For my use case, it would be enough to use whatever .pyc files the
interpreter finds. For a testing scenario, it is fine to delete all the
.pyc files, set PYTHONPEEPHOLE, and then run the test suite to be sure
to avoid optimized pyc files.
>
> Paul
More information about the Python-ideas
mailing list