How to disable assert statements inside a module?
Pearu Peterson
pearu at cens.ioc.ee
Sun Mar 10 15:06:44 EST 2002
Hi,
Is there a way to disable all assert statements inside a module,
and without calling python with -O switch?
Why? I have developed a module using lots of assert statements (yes,
they are all relevant). Now when it is finished, I found that
running python with -O switch the speed up is approximately 4 times. I
assume that this is due to disabled assert statements. I don't want to
remove all these assert statements because I might extend this module in
future when they will be handy again for debugging.
Next, I want to use this module from other modules that use it
extensively. But then, I would expect a remarkable slow down because of
the irrelevant assert statements in the first module.
So, I would like to disable the assert statements in one module while in
others, that are under development, assert statements are enabled.
Is it possible? I am using Python 2.2.
Thanks,
Pearu
More information about the Python-list
mailing list