[Python-ideas] Dynamic code NOPing
Stefan Behnel
stefan_ml at behnel.de
Sun Dec 30 11:58:21 CET 2012
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 !")
More information about the Python-ideas
mailing list