PyMOTW: compileall

The compileall module finds Python source files and compiles them to the byte-code representation, saving the results in .pyc or .pyo files.

Read more at pymotw.com: compileall