On Mon, 2018-05-07 at 10:52 -0700, Guido van Rossum wrote:
On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka
wrote: I just don't understand why you need a new keyword for writing runtime checks.
Oh, that's pretty clear. The OP wants to be able to turn these checks off with some flag he can set/clear at runtime, and when it's off he doesn't want to incur the overhead of evaluating the check. The assert statement has the latter property, but you have to use -O to turn it off. 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. :-)
and he already has a diff ready for review if needed (basically very similar to the current 'assert' implementation :)