python -O does the following currently:
- completely ignores asserts
- sets the special builtin name
__debug__
to False (which by default is True)
and when called as python -OO
- removes docstrings from the code
I don’t know why everyone forgets to mention the __debug__
issue; perhaps it is because I’m the only one using it 🙂 An if __debug__
construct creates no bytecode at all when running under -O
, and I find that very useful.