compileall.compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1)
Compile the file with path fullname.
If ddir is given, it is prepended to the path to the file being compiled for use in compilation time tracebacks, and is also compiled in to the byte-code file, where it will be used in tracebacks and other messages in cases where the source file does not exist at the time the byte-code file is executed.
If rx is given, its search method is passed the full path name to the file being compiled, and if it returns a true value, the file is not compiled and True
is returned.
If quiet is False
or 0
(the default), the filenames and other information are printed to standard out. Set to 1
, only errors are printed. Set to 2
, all output is suppressed.
If legacy is true, byte-code files are written to their legacy locations and names, which may overwrite byte-code files created by another version of Python. The default is to write files to their PEP 3147 locations and names, which allows byte-code files from multiple versions of Python to coexist.
optimize specifies the optimization level for the compiler. It is passed to the built-in compile()
function.
New in version 3.2.
Changed in version 3.5: quiet parameter was changed to a multilevel value.
Changed in version 3.5: The legacy parameter only writes out .pyc
files, not .pyo
files no matter what the value of optimize is.
Please login to continue.