[Python-ideas] Disable all peephole optimizations

Brett Cannon bcannon at gmail.com
Wed May 21 15:51:48 CEST 2014


On Wed May 21 2014 at 9:05:48 AM, Paul Moore <p.f.moore at gmail.com> 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.
>

There are constant rumblings about trying to make .pyc/.pyo aware of what
optimizations were applied so that this kind of thing wouldn't occur. It
would require tweaking how optimizations are expressed/added so that they
are more easily controlled and can somehow contribute to the labeling of
what optimizations were applied. All totally doable but will require
thinking about the proper API and such (reading .pyc/.pyo files would also
break but that's happened before when we added file size to the header and
.pyc/.pyo files are viewed as internal optimizations anyway).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140521/9868fb81/attachment.html>


More information about the Python-ideas mailing list