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

Kyle Lahnakoski klahnakoski at mozilla.com
Tue Jun 5 13:25:45 EDT 2018


I currently use the form

    <control_flag> and log_function( <msg_expr> )

where <control_flag> is some module variable, usually "DEBUG".  I do
this because it is one line, and it ensures the log_function parameters
are not evaluated.

*IF* runtime assertions had a switch so they have no overhead when not
active, how much faster can it get?  How expensive is the <control_flag>
check?


On 2018-05-10 03:55, Barry Scott wrote:
>
> My logging example would be
>
> log( control_flag, msg_expr )
>
> expanding to:
>
> if <control_flag>:
> log_function( <msg_expr> )
>
> Barry
>
> This idea requires the same sort of machinery in python that I was
> hoping for to implement the short circuit logging.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180605/31fe011c/attachment.html>


More information about the Python-ideas mailing list