05.05.18 11:04, Eloi Gaudry пише:
    Briefly, the idea is to add a new assert that can be switch on/off
    depending on some variable/mechanism at runtime. The whole point of
    this assert is that it should not bring any overhead when off, i.e.
    by avoiding evaluating the expression enclosed in the runtime
    assert. It thus relies on Python grammar.

You should have an overhead for checking if it is switched on/off, isn't? And this overhead is virtually the same as testing the value of the global boolean variable.

runtime_assert( expr )

#would result in if expr and runtime_assert_active:

print RuntimeAssertionError()

How this will be different from

    if debug and not expr:
        print(RuntimeAssertionError())

?

_______________________________________________
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