0

I want to invalidate the "assert" in my Python codes when I run it as a release edition. Consider that a lot of "assert" may be used in my files in the developing procedure, but I want to skip the compiling of "assert" to enhance the efficiency. Is there some simple method like a pre_define of "NDEBUG" in c++ ?

Sean Lau
  • 11
  • 1

1 Answers1

1

Use command line option -O. As described in the docs:

In the current implementation, the built-in variable __debug__ is True under normal circumstances, False when optimization is requested (command line option -O). The current code generator emits no code for an assert statement when optimization is requested at compile time.

jpp
  • 159,742
  • 34
  • 281
  • 339