[issue14868] Allow log calls to return True for code optimization.

Lluís report at bugs.python.org
Mon May 21 13:26:10 CEST 2012


Lluís <llpamies at pamies.cat> added the comment:

David, the problem is that if you have the logging inside a loop, the interpreter will have to evaluate the condition every time. With an assert you guarantee that *no code* is executed.

I know that we can find thousands of ways to do that, even writing a dynamic proxy for the Logger, and wrap the debug(), error() calls and return True, etc.

My is not telling developers to write "assert logger.debug('aa')" every time that they want to log something, but instead giving them the option to do that and be sure that *no code* is executed. Specially, because the return value of log functions is not used at all.

Thanks for the responses.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14868>
_______________________________________


More information about the Python-bugs-list mailing list