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

Steven D'Aprano steve at pearwood.info
Tue May 8 11:34:34 EDT 2018

On Tue, May 08, 2018 at 07:37:55AM +0000, Eloi Gaudry wrote:

> * 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.

I don't think that is a useful distinction to make.

I use `assert` all the time, and I have never once cared whether it is a 
"debug build" or a "production build". I use assert in my code, and then 
people (including me) can use it with whatever build of Python they 

I don't even know which builds of Python I'm running. My *guess* is that 
the OS-provided Python is probably a non-debug build, and the ones I've 
compiled from source will be whatever the default build settings are, 
but I don't know what that is or how to find out.

And if there was some sort of runtime_assert that could be enabled and 
disabled individually, why wouldn't I use it with debug builds as well 
as non-debug builds?


More information about the Python-ideas mailing list