By 'self-contained', I meant that using the assert keyword and its expression 
is sufficient. An inline assertive expression as the one you describe does not 
fulfill this assert requirement.

My proposal is simply to extend the current assert to non-debug builds and 
allow to switch it off/on at runtime.

The syntax example I gave illustrated what I meant by syntax aware.



De : Serhiy Storchaka
Envoyé : samedi 5 mai à 15:10
Objet : Re: [Python-ideas] Runtime assertion with no overhead when not active
À : python-ideas@python.org


05.05.18 15:54, Eloi Gaudry пише: > I meant avoiding the overhead of the 
expression evaluation enclosed in the assert itself, not the active/disabled 
state (that comes at virtually no cost). > ex: >>>> runtime_assert( { i:None 
for i in range( 10000000 ) } ) > > By using the syntax you describe ('boolean 
and not expr'), you loose all the benefit of the Python grammar: > - 
self-contained Could you please explain what you mean? > - able to catch 
semantic/syntax bugs > > ex: >>>> f=1 >>>> runtime_assert( f==1 ) >>>> 
runtime_assert( f=1 ) > File "", line 1 > runtime_assert( f=1 ) > ^ > 
SyntaxError: invalid syntax Until inline assignment expression is implemented, 
this is an error too: >>> if debug and not f=1: File "", line 1 if debug and 
not f=1: ^ SyntaxError: invalid syntax 
_______________________________________________ Python-ideas mailing list 
Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas 
Code of Conduct: http://python.org/psf/codeofconduct/



_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to