Hi,

2015-10-22 19:02 GMT+02:00 Brett Cannon <br...@python.org>:
> It's not specified anywhere; it's just what the peepholer decides to remove.
> The exact code can be found at
> https://hg.python.org/cpython/file/default/Python/peephole.c . There has
> been talk in the past for adding a -X flag to disable the peepholer, but it
> never went any farther beyond that.

Yeah, I remember that I had the same issue than Stéphane when I worked
on my astoptimizer project :-) I wanted to completly disable the
peephole optimizer because I wanted to reimplement the optimizations
on the AST instead of rewriting the bytecode.

I would be nice to have a "-X noopt" command line option for that.

By the way, the peephole optimizer cannot remove "if 0: yield" because
it's a workaround of a limitation in CPython. It's not possible to
declare that a function is a generator even if it doesn't call yield.
Well, "async def" solves partially the issue, but sometimes you don't
want generators with "async def".

If I recall correctly, another usecase of "-X noopt" is code coverage:
the peephole optimizers punchs holes in the code coverage because it
looks like some lines are never executed.

Note: I propose "noopt" because we already have "optimization level 0"
which still uses optimizations, it's the default mode. It's different
than gcc -O0 which really disables all optimizations. I already prefix
the "noopt" suffix for .pyc files than "opt--1" proposed by Brett in
http://bugs.python.org/issue2506

Victor
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to