18.8 py_compile -- Compile Python source files

 The py_compile module provides a single function to generate a byte-code file from a source file.

Though not often needed, this function can be useful when installing modules for shared use, especially if some of the users may not have permission to write the byte-code cache files in the directory containing the source code.

compile(file[, cfile[, dfile]])
Compile a source file to byte-code and write out the byte-code cache file. The source code is loaded from the file name file. The byte-code is written to cfile, which defaults to file + 'c' ('o' if optimization is enabled in the current interpreter). If dfile is specified, it is used as the name of the source file in error messages instead of file.

See Also:

Module compileall:
Utilities to compile all Python source files in a directory tree.
See About this document... for information on suggesting changes.