📘 Help on module compileall:
compileall - Module/script to byte-compile all .py files to .pyc files.
| Use Case | Command | Description |
|---|---|---|
| Compile a directory recursively | python -m compileall <dir> | Byte-compile all .py files in directory tree |
| Compile without recursion | python -m compileall -l <dir> | Compile only top-level .py files |
| Force recompilation | python -m compileall -f <dir> | Force compilation even if timestamps are up-to-date |
| Quiet mode (errors only) | python -m compileall -q <dir> | Suppress normal output, show only errors |
| Silent mode | python -m compileall -qq <dir> | No output at all |
| Parallel compilation | python -m compileall -j <N> <dir> | Use N parallel workers |
| Produce legacy pyc paths | python -m compileall -l <dir> | Use PEP 3147-incompatible paths |
| Compile all modules on sys.path | python -m compileall | Compile all modules in sys.path directories (no recursion) |
https://docs.python.org/3.10/library/compileall.html
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
When called as a script with arguments, this compiles the directories given as arguments recursively; the -l option prevents it from recursing into directories.
Without arguments, it compiles all modules on sys.path, without recursing into subdirectories. (Even though it should do so for packages — for now, you'll have to deal with packages separately.)
See module py_compile for details of the actual byte-compilation.
compile_dir(dir, maxlevels=None, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False)Byte-compile all modules in the given directory tree.
Arguments (only dir is required):
dir — the directory to byte-compilemaxlevels — maximum recursion level (default sys.getrecursionlimit())ddir — the directory that will be prepended to the path to the file as it is compiled into each byte-code fileforce — if True, force compilation, even if timestamps are up-to-daterx — regular expression to filter filesquiet — full output with False or 0, errors only with 1, no output with 2legacy — if True, produce legacy pyc paths instead of PEP 3147 pathsoptimize — int or list of optimization levels or -1 for level of the interpreter. Multiple levels leads to multiple compiled files each with one optimization levelworkers — maximum number of parallel workersinvalidation_mode — how the up-to-dateness of the pyc will be checkedstripdir — part of path to left-strip from source file pathprependdir — path to prepend to beginning of original file path, applied after stripdirlimit_sl_dest — ignore symlinks if they are pointing outside of the defined pathhardlink_dupes — hardlink duplicated pyc filescompile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None, hardlink_dupes=False)Byte-compile one file.
Arguments (only fullname is required):
fullname — the file to byte-compileddir — if given, the directory name compiled in to the byte-code fileforce — if True, force compilation, even if timestamps are up-to-daterx — regular expressionquiet — full output with False or 0, errors only with 1, no output with 2legacy — if True, produce legacy pyc paths instead of PEP 3147 pathsoptimize — int or list of optimization levels or -1 for level of the interpreter. Multiple levels leads to multiple compiled files each with one optimization levelinvalidation_mode — how the up-to-dateness of the pyc will be checkedstripdir — part of path to left-strip from source file pathprependdir — path to prepend to beginning of original file path, applied after stripdirlimit_sl_dest — ignore symlinks if they are pointing outside of the defined pathhardlink_dupes — hardlink duplicated pyc filescompile_path(skip_curdir=1, maxlevels=0, force=False, quiet=0, legacy=False, optimize=-1, invalidation_mode=None)Byte-compile all module on sys.path.
Arguments (all optional):
skip_curdir — if true, skip current directory (default True)maxlevels — max recursion level (default 0)force — as for compile_dir() (default False)quiet — as for compile_dir() (default 0)legacy — as for compile_dir() (default False)optimize — as for compile_dir() (default -1)invalidation_mode — as for compile_dir()__all__ = ['compile_dir', 'compile_file', 'compile_path']
/usr/lib/python3.10/compileall.py
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 16:55 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)