Author Mark.Shannon
Recipients Mark.Shannon, nedbat, rhettinger, serhiy.storchaka
Date 2020-12-21.13:55:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608558922.78.0.231281591851.issue42693@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-12-21 13:55:22Mark.Shannonsetrecipients: + Mark.Shannon, rhettinger, nedbat, serhiy.storchaka
2020-12-21 13:55:22Mark.Shannonsetmessageid: <1608558922.78.0.231281591851.issue42693@roundup.psfhosted.org>
2020-12-21 13:55:22Mark.Shannonlinkissue42693 messages
2020-12-21 13:55:22Mark.Shannoncreate