I think this summarizes the situation very well :) https://xkcd.com/1172/
On Fri, 5 Jul 2019 at 22:28, Pablo Galindo Salgado <pablog...@gmail.com> wrote: > Hi, > > Recently, we moved the optimization for the removal of dead code of the > form > > if 0: > .... > > to the ast so we use JUMP bytecodes instead (being completed in PR14116). > The reason is that > currently, any syntax error in the block will never be reported. For > example: > > if 0: > return > > if 1: > pass > else: > return > > while 0: > return > > > at module level do not raise any syntax error (just some examples), In > https://bugs.python.org/issue37500 it was reported > that after that, code coverage will decrease as coverage.py sees these new > bytecodes (even if they are not executed). In general, > the code object is a bit bigger and the optimization now it requires an > JUMP instruction to be executed, but syntax errors are reported. > > The discussion on issue 37500 is about if we should prioritize the > optimization or the correctness of reporting syntax errors. In my opinion, > SyntaxErrors should be reported with independence of the value of > variables (__debug__) or constant as is a property of the code being written > not of the code being executed. Also, as CPython is the reference > implementation of Python, the danger here is that it could be interpreted > that > this optimization is part of the language and its behavior should be > mirrored in every other Python implementation. Elsewhere we have always > prioritize correctness over speed or optimizations. > > I am writing this email to know what other people think. Should we revert > the change and not report Syntax Errors on optimized blocks? Someone > sees a viable way of reporting the errors and not emitting the bytecode > for these block? > > Regards, > Pablo > >
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/M4SMPVBNGTOFLTQP6LKO5C34OSSVWVUR/