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

Eloi Gaudry Eloi.Gaudry at fft.be
Tue May 8 03:37:55 EDT 2018


On Mon, 2018-05-07 at 16:56 +0000, Brett Cannon wrote:
> 
> 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? 

Not so much different, except that:
- the switch won't need to be on the command line
- the 2 different asserts would be considered differently by
developers/users : 
* debug assert, for helping developing a new features, used with debug-
builds
* runtime assert, for ensuring correctness and/or diagnosing issue with
production/release-builds on-site.


More information about the Python-ideas mailing list