Optimizing constants in loops

Michael Hoffman cam.ac.uk at mh391.invalid
Wed Jun 13 13:17:03 EDT 2007


Thomas Heller wrote:

> Just use the builtin __debug__ variable for that purpose.
> __debug__ is 'True' if Python is run normally, and 'False'
> if run with the '-O' or '-OO' command line flag.
> The optimizer works in the way you describe above (which
> it will not if you use a custom variable).

Thanks, I didn't know that __debug__ was optimized like this. But that 
was really just a specific example of the general case.
-- 
Michael Hoffman



More information about the Python-list mailing list