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

Brett Cannon brett at python.org
Mon May 7 12:56:37 EDT 2018

On Mon, 7 May 2018 at 06:28 Serhiy Storchaka <storchaka at gmail.com> wrote:

> 07.05.18 12:58, Eloi Gaudry пише:
> > I didn't mean to replace the current (debug) assert but I wanted to add
> > another one that would allow to be switch on or off on production builds.
> >
> > The need for a new keyword (not syntax) comes from this difference.
> >
> >
> >   I cannot think of another example that would convince you of the
> > benefit of having a specific keyword for such a runtime assert.  I do
> > believe that having such a feature in non-debug build is more than
> > interesting but indeed needed.
> I just don't understand why you need a new keyword for writing runtime
> checks.

My question is how is this different to running with -O which leaves the
assert statement out of the bytecode and so you avoid any run-time cost of
the statement entirely?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180507/0c9675e2/attachment.html>

More information about the Python-ideas mailing list