__debug__ and trace_level (was: Python benchmark script)

Michael Ströder michael at stroeder.com
Tue Jun 24 09:52:45 CEST 2003


Ed,

Cc:-ed list since this might be of general interest.

Ed . wrote:
> 
> I'm pleased to hear that there are optimisations which can be made, not 
> sure I understand the reference to __debug__.

http://www.python.org/doc/current/ref/assert.html#l2h-310

> Perhaps it's a 
> documentation problem and that logging should be off by default and 
> enabled for those doing debugging?

Logging is off by default (trace_level=0). But the if-statements checking 
trace_level are executed if the Python interpreter was invoked without -O.

If running with -O it is my understanding that code behind if __debug__ is 
completely optimized away and never executed. Therefore tracing is only 
available when running without -O.

Ciao, Michael.



More information about the python-ldap mailing list