The check is made against a boolean value in the C extension, I don't think 
that it offers a significant speed-up against the pure python code.

but it offers a simpler (reduced, global) assertion syntax though.

________________________________
From: Python-ideas <python-ideas-bounces+eloi.gaudry=fft...@python.org> on 
behalf of Kyle Lahnakoski <klahnako...@mozilla.com>
Sent: Tuesday, June 5, 2018 7:25:45 PM
To: python-ideas@python.org
Subject: Re: [Python-ideas] Runtime assertion with no overhead when not active



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.



_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to