What are the implications of running python with the optimize flag?

前端 未结 4 1178
感情败类
感情败类 2020-12-30 19:46

I cannot seem to find a good simple explanation of what python does differently when running with the -O or optimize flag.

4条回答
  •  太阳男子
    2020-12-30 20:04

    assert statements are completely eliminated, as are statement blocks of the form if __debug__: ... (so you can put your debug code in such statements blocks and just run with -O to avoid that debug code).

    With -OO, in addition, docstrings are also eliminated.

提交回复
热议问题