If you mark constant.DEBUG as constant and compile your project with astoptimizer, enable_debug has no effect (if it was compiled with DEBUG=False).

So only use it if DEBUG will not be changed at runtime. It cannot be used if your users might run your applucation in debug mode.

To compare it to the C language, DEBUG would be a #define and astoptimizer can be see as a preprocessor.

Victor

Le 30 déc. 2012 11:59, "Stefan Behnel" <stefan_ml@behnel.de> a écrit :
Victor Stinner, 30.12.2012 11:42:
> My astoptimizer provides tools to really *remove* debug at compilation, so
> the overhead of the debug code is just null.
>
> You can for example declare your variable project.config.DEBUG as constant
> with the value 0, where project.config is a module. So the if statement in
> "from project.config import DEBUG ... if DEBUG: ..." will be removed.

How would you know at compile time that it can be removed? How do you
handle the example below?

Stefan


## constants.py

DEBUG = False


## enable_debug.py

import constants
constants.DEBUG = True


## test.py

import enable_debug
from constants import DEBUG

if DEBUG:
    print("DEBUGGING !")


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas