Mark Shannon <m...@hotpy.org> added the comment:

You should never have to disable optimizations.

Let's be clear about what an optimization is.

An optimization (CS not math) is a change to the program such that it has the 
same effect, according to the language spec, but improves some aspect of the 
behavior, such as run time or memory use.

Any transformation that changes the effect of the program is not an 
optimization.

You shouldn't be able to tell, without timing the program (or measuring memory 
use, observing race conditions, etc.) whether optimizations are turned on or 
not.

Removing bytecodes for dead code is a legal optimization. It can never run, so 
we can't tell by observation whether it is there or not.

PEP 626 makes the lines number traced part of the language specification.
So the optimizer *must* respect line numbers.

Thus, removing all trace of `if 0:` is not legal since we could observe that 
change.
Hypothetically, we could change the line number table to allow multiple lines 
per bytecode and remove the NOP. The important point is that is coverage.py 
shouldn't care, or even know, if we do so.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42693>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to