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

2012-05-21 Thread Lluís
New submission from Lluís llpam...@pamies.cat: One of the problems with the logging library is that it can affect code performance when logging calls are over-utilized. One possible solution would be to allow the compiler to remove logging calls when code is optimized with python -O by

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

2012-05-21 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: assert logging.debug(This is a test.) or True -- nosy: +storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14868 ___

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

2012-05-21 Thread Lluís
Lluís llpam...@pamies.cat added the comment: storchaka, you're right, but since non of the debug(), info() etc. functions have a return value, it would cause no trouble and would be neater to add a return True. I'm not sure, but probably also more efficient. --

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

2012-05-21 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I would also, however, not be a typical Python coding pattern. Functions normally return None by default. The 'assertor True' pattern makes it reasonably clear what the intent is, which just having logging return True would not,

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

2012-05-21 Thread Lluís
Lluís llpam...@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

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

2012-05-21 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I was definitely wrong about the obvious part, then. The 'if __debug__:' idiom is completely optimized away by -O, just like asserts are. That is, in -O mode, there is no if test, the code block is just omitted entirely. Having said

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

2012-05-21 Thread Lluís
Lluís llpam...@pamies.cat added the comment: Thanks for the explanation, I didn't know of the exact behavior of __debug__. I close ticket. -- resolution: - works for me status: open - closed ___ Python tracker rep...@bugs.python.org