{"slug":"ref-python-279d1ed585e898888e89","title":"compileall --- Byte-compile Python libraries — Public functions","summary":"Recursively descend the directory tree named by dir, compiling all .py files along the way.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nRecursively descend the directory tree named by dir, compiling all .py files along the way. Return a true value if all the files compiled successfully, and a false value otherwise.\n\nThe maxlevels parameter is used to limit the depth of the recursion; it defaults to sys.getrecursionlimit().\n\nIf ddir is given, it is prepended to the path to each 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.\n\nIf force is true, modules are re-compiled even if the timestamps are up to date.\n\nIf rx is given, its search method is called on the complete path to each file considered for compilation, and if it returns a true value, the file is skipped. This can be used to exclude files matching a regular expression, given as a re.Pattern object.\n\nIf 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.\n\nIf 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 3147 locations and names, which allows byte-code files from multiple versions of Python to coexist.\n\noptimize specifies the optimization level for the compiler. It is passed to the built-in compile function. Accepts also a sequence of optimization levels which lead to multiple compilations of one .py file in one call.\n\nThe argument workers specifies how many workers are used to compile files in parallel. The default is to not use multiple workers. If the platform can't use multiple workers and workers argument is given, then sequential compilation will be used as a fallback. If workers is 0, the number of cores in the system is used. If workers is lower than 0, a ValueError will be raised.\n\ninvalidation_mode should be a member of the py_compile.PycInvalidationMode enum and controls how the generated pycs are invalidated at runtime.\n\nThe stripdir, prependdir and limit_sl_dest arguments correspond to the -s, -p and -e options described above. They may be specified as str or os.PathLike. …\n\nAttribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","python","library","compileall","byte-compile","libraries","public","functions"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/python/cpython/blob/f10166035d602da5052e8a48f9d5c216c57b401d/Doc/library/compileall.rst","source_name":"Python Documentation","source_license":"PSF-2.0","source_revision":"f10166035d602da5052e8a48f9d5c216c57b401d","source_path":"Doc/library/compileall.rst :: Public functions","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.532403+00:00","url":"https://wikikv.com/k/ref-python-279d1ed585e898888e89","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-python-279d1ed585e898888e89","markdown":"https://wikikv.com/k/ref-python-279d1ed585e898888e89?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-python-279d1ed585e898888e89","json_ld":"https://wikikv.com/k/ref-python-279d1ed585e898888e89?format=jsonld"}}