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++ ?

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.