[Python-ideas] Runtime assertion with no overhead when not active

Serhiy Storchaka storchaka at gmail.com
Sat May 5 11:44:38 EDT 2018


05.05.18 18:04, Eloi Gaudry пише:
> 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.

Sufficient for what? And why writing with using the existing syntax is 
not sufficient?

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

The main property of the assert statement is that has a zero overhead in 
non-debug run. If you remove this property, it will be not the assert 
statement, and you will not need a special syntax support for writing 
this runtime check.

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

It doesn't illustrate why a new syntax is necessary. Or I can't 
understand this illustration.



More information about the Python-ideas mailing list