[Python-Dev] ',' precedence in documentation
"Martin v. Löwis"
martin at v.loewis.de
Sun Sep 14 22:59:23 CEST 2008
> Doesn't this change the behavior in optimized code, for assert
> statements with side effects?
That's why I said it will be a long discussion :-)
I would also propose the elimination of the -O option, and the notion
of optimized code. People who want to save the time for execution of the
assert statements could use some kind of source transformation, which
might be easy to implement with lib2to3 (or a generalization thereof).
> If we don't have specialized syntax --
> that is, if 'assert' just becomes another built-in function -- then it
> can't be special-cased in the translation to byte-code, can it?
It still could. First, assert may continue to be a statement, even
though it is invoked as a function call, similar to None, True, False.
In that case, the compiler could still eliminate it, or (IMO preferred),
wrap it into a conditional statement that checks whether assertions are
disabled, and, if so, jumps over the assertion.
Even if it isn't a keyword, the compiler could still special-case it,
and add a run-time check to determine whether assert is still bound to
the built-in assert.
More information about the Python-Dev