[Python-ideas] Python-ideas Digest, Vol 90, Issue 30

Ned Batchelder ned at nedbatchelder.com
Thu May 22 15:24:37 CEST 2014


On 5/22/14 2:44 AM, Terry Reedy wrote:
> On 5/21/2014 6:59 PM, Ned Batchelder wrote:
>
>> If by implementation details, you mean the word "peephole", then let's
>> remove it, and simply have a switch that disables all optimization.
>> Rather than limiting the future of the optimizer, it will provide an
>> escape hatch for people who would rather not have the optimizer's 
>> effects.
>
> The presumption of this idea is that there is a proper, canonical 
> unoptimized version of 'compiled Python'. For Python there obviously 
> is not. For CPython, there is not either. What Raymond has been saying 
> is that the output of the CPython compiler is the output of the 
> CPython compiler.
>

I'd like to understand why we think the Python compiler is different in 
this regard than a C compiler.  We all use C compilers that have a -O0 
switch.  It's there to disable optimizations so that programs can be 
debugged.  The C compiler also has no "canonical unoptimized compiled 
output".  But the switch is there to make it possible to debug (reason 
about) the compiled code.

I don't care if we have a command line switch or some other mechanism to 
disable optimizations. I just think it's useful to be able to do it somehow.

When this came up 18 months ago on Python-Dev, it was part of a thread 
about adding more optimizations to CPython.  Guido said "+1" to the idea 
of being able to disable the optimizers 
(https://mail.python.org/pipermail/python-dev/2012-December/123099.html). Our 
need is not as great as C's, the unrecognizability of the compiled code 
is much less, but current optimizations are already interfering with the 
ability to debug and analyze code, and new optimizations will only 
broaden the possibility of interference.

--Ned.




More information about the Python-ideas mailing list