[Python-ideas] Disable all peephole optimizations
Ethan Furman
ethan at stoneleaf.us
Thu May 22 19:29:48 CEST 2014
On 05/22/2014 08:41 AM, Steve Dower wrote:
> Guido van Rossum wrote:
>>
>> FWIW, I am strictly with Ned here.
>
> As someone who maintains/develops a debugger for Python, I’m with
> Ned as well (and also Raymond, since I really don’t want to have
> to worry about one-more-mode that Python might be running in).
>
> Why not move the existing optimisation into -O mode and put future
> optimisations in there too? It may just start having enough value
> that people switch to using it.
I will admit to being very surprised the day I realized that the normal run mode for python is debugging mode!
For anyone who hasn't yet realized this, without -O, __debug__ is True, but with any -O __debug__ is False. Given that,
it does seem kind of odd to have source altering optimizations active when __debug__ is True.
Of course, we can't change that mid-3.x stream.
However, we could turn off optimizations by default, and then have -O remove assertions /and/ turn on optimizations.
Which would still work nicely with .pyc and .pyo files as ... wait, let me make a table:
flag | optimizations | saved files
--------+--------------------+--------------
none | none | none
--------+--------------------+--------------
-O | asserts removed | .pyc
| peephole, etc. |
--------+--------------------+--------------
-OO | -O plus |
| docstrings removed | .pyo
That would certainly make the -O flags make more sense than they do now. It would also emphasize the fact that assert
is not for user data verification. ;)
--
~Ethan~
More information about the Python-ideas
mailing list