What is the difference between pyc and pyo files in Python?
compilation, python
Solution
`.pyc` files are python files compiled to byte code by the interpreter. They are generated normally when a file is imported.
`.pyo` are compiled byte code without line numbers, assertions, and some other things (possibly doc strings) for optimization purposes.
when invoking the python interpreter, you may pass the `-O` or `-OO` option to generate a `.pyo` file. Using `-O` will throw out the line numbers, assertions, and some debugging info. `-OO` will result in a `.pyo` file also stripped of docstrings.
Problem
I see that .pyc and .pyo file are both compiled python code. What is difference between them and when I should use one or another?