


Third: Python's -OO option also implements some optimizations as per the -O command line option this may result in changes in operation. Second: If docstrings are skipped with the use of the -OO command line option as described above, no one will be able to get at that information, which can make use of the code more difficult (or impossible.) py to recompile or touch so it supersedes the. If you distribute one of these files into an environment of a different type, it will break. pyo files that indicates the system architecture that the python file was compiled in. pyo benefits back again again, such as they may be.įirst: There's a "magic cookie" in. You need to recompile it in order to get the.

pyo is obsolete and whatever benefits you gained are lost. py file's date, if it is present, to decide whether it should execute the. pyc file equally distributable in terms of the code's essential functionality, but smaller by the size of the stripped-out docstrings (and less easily understood for subsequent employment if it had decent docstrings in the first place). If you'd like to get rid of the docstrings as well (you might want to seriously think about why you're doing that) then compile this way instead. pyc file this way: python -m py_compile myscript.py It is useful to know that you can compile a top level python source file into a. Sixth: if you're aiming at an embedded system, obtaining a smaller sizeįile to embed may represent a significant plus, and the architecture is stable so drawback one, detailed below, does not come into play. pyo file in hand is much less likely to present you with a bug they caused by an un-reverted change they forgot to tell you about. pyo file will be in comparison to the source. Nice for the CPU and the web.įourth: the more you comment, the smaller the. Third: Python can skip the compilation step. Second: if compilation results in a significantly smaller file, you will get faster load times.
