[Python-ideas] Efficient debug logging
Giampaolo Rodola'
g.rodola at gmail.com
Thu Feb 16 09:24:54 EST 2017
On Thu, Feb 16, 2017 at 1:55 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> Some comments:
>
> 1. you don't need a preprocessor for this: simply put your
> logging code into an "if __debug__:" block:
>
> https://docs.python.org/3.6/reference/simple_stmts.html?
> the-assert-statement#grammar-token-assert_stmt
> and then run your production code with "python -O"
> (the trick here is that the Python byte code compiler will
> not even generate code for such ifs)
I didn't know about if __debug__ + -O:.
Unbelievable after so many years.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170216/b08f47cd/attachment.html>
More information about the Python-ideas
mailing list