if __debug__:log(factorial(2**15))Running python with -O will squash this statement. To have something inline, you could also abuse assert statements to do the job.
def debug_log(x):log(x)return Trueassert debug_log(factorial(2**15))In optimized builds, the statement will be removed entirely.
On Tue, Dec 25, 2012 at 1:28 AM, anatoly techtonik <techtonik@gmail.com> wrote:
For the logging module it will be extremely useful if Python included a way to disactivate processing certain blocks to avoid making sacrifices between extensive logging harness and performance. For example, instead of writing:if log.DEBUG==True:log(factorial(2**15))It should be possible to just write:log(factorial(2**15))
if if log() is an instance of some Nopable class, the statement in log's braces is not executed.--anatoly t._______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas
--
Jasper
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas