compileall.compile_dir()
compileall.compile_dir() is a Python function in the Compileall Module category. Compiles all .py files in a directory to .pyc bytecode. The syntax is compileall.compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None). Returns: Boolean (True if all compiled). A typical example: import compileall
compileall.compile_dir(".") # Compile all .py in current dir. A close sibling is compileall.compile_file(), which compiles a single .py file to .pyc. A close sibling is compileall.compile_path(), which compiles all .py files on sys.path. More about this category: Bytecode compilation — compile_dir, compile_file, compile_path. Related Compileall Module entries: compileall.compile_file(), compileall.compile_path(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try compileall.compile_dir() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.