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

Serhiy Storchaka storchaka at gmail.com
Tue May 8 11:52:02 EDT 2018


07.05.18 20:52, Guido van Rossum пише:
> He basically wants a macro so that
> 
>    runtime_assert(<expr>)
> 
> expands to
> 
>    if <controlling flag> and (<expr>):
>        raise AssertionError
> 
> In Lisp this would be easy. :-)

Python is not Lisp (still). But there is the MacroPy project. And at end 
you always can use an external tool for code generation. For example the 
old good cpp.



More information about the Python-ideas mailing list