[Python-ideas] Runtime assertion with no overhead when not active
Guido van Rossum
guido at python.org
Tue May 8 10:37:30 EDT 2018
On Tue, May 8, 2018 at 12:29 AM, Eloi Gaudry <Eloi.Gaudry at fft.be> wrote:
> On Mon, 2018-05-07 at 10:52 -0700, Guido van Rossum wrote:
> > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka <storchaka at gmail.com
> > > 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 :)
That seems premature. There is not even a hint of agreement that such a
feature would be useful *in general* (I'm not doubting your situation) and
worth our limited volunteer developer resources to maintain, document etc.
for decades to come.
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas