[issue26204] compiler: don't emit LOAD_CONST instructions for constant statements?

STINNER Victor report at bugs.python.org
Tue Jan 26 17:09:08 EST 2016


STINNER Victor added the comment:

Serhiy: "It looks to me that this optimization was added to avoid spending executing time for docstrings. Other cases almost never occur in real code and are not worth to be optimized. But the patch makes the code cleaner (it would even more cleaner if collapse all kinds of constants in Constant)."

Oh, I don't really care of performance. The bytecode just doesn't make any sense to me. I don't understand why we load a constant.

Maybe the compiler should emit a warning to say that the code doesn't make sense at all and is ignored?

Example with GCC:

$ cat x.c 
int main()
{
    1;
}


$ gcc x.c -Wall -o x
x.c: In function 'main':
x.c:3:5: warning: statement with no effect [-Wunused-value]
     1;
     ^

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26204>
_______________________________________


More information about the Python-bugs-list mailing list