Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
compileall.html722 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="compileall — Byte-compile Python libraries" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/compileall.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/compileall.py This module provides some utility functions to support installing Python libraries. These functions compile Python source files in a directory tree. This module can b..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_compileall_6b987675.png" />15<meta property="og:image:alt" content="Source code: Lib/compileall.py This module provides some utility functions to support installing Python libraries. These functions compile Python source files in a directory tree. This module can b..." />16<meta name="description" content="Source code: Lib/compileall.py This module provides some utility functions to support installing Python libraries. These functions compile Python source files in a directory tree. This module can b..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>compileall — Byte-compile Python libraries &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="dis — Disassembler for Python bytecode" href="dis.html" />43    <link rel="prev" title="py_compile — Compile Python source files" href="py_compile.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/compileall.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h3><a href="../contents.html">Table of Contents</a></h3>106    <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code> — Byte-compile Python libraries</a><ul>108<li><a class="reference internal" href="#command-line-use">Command-line use</a></li>109<li><a class="reference internal" href="#public-functions">Public functions</a></li>110</ul>111</li>112</ul>113 114  </div>115  <div>116    <h4>Previous topic</h4>117    <p class="topless"><a href="py_compile.html"118                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">py_compile</span></code> — Compile Python source files</a></p>119  </div>120  <div>121    <h4>Next topic</h4>122    <p class="topless"><a href="dis.html"123                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code> — Disassembler for Python bytecode</a></p>124  </div>125  <script>126    document.addEventListener('DOMContentLoaded', () => {127        const title = document.querySelector('meta[property="og:title"]').content;128        const elements = document.querySelectorAll('.improvepage');129        const pageurl = window.location.href.split('?')[0];130        elements.forEach(element => {131            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));132            url.searchParams.set('pagetitle', title);133            url.searchParams.set('pageurl', pageurl);134            url.searchParams.set('pagesource', "library/compileall.rst");135            element.href = url.toString();136        });137    });138  </script>139  <div role="note" aria-label="source link">140    <h3>This page</h3>141    <ul class="this-page-menu">142      <li><a href="../bugs.html">Report a bug</a></li>143      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>144      <li>145        <a href="https://github.com/python/cpython/blob/main/Doc/library/compileall.rst?plain=1"146            rel="nofollow">Show source147        </a>148      </li>149      150    </ul>151  </div>152        </nav>153    </div>154</div>155 156  157    <div class="related" role="navigation" aria-label="Related">158      <h3>Navigation</h3>159      <ul>160        <li class="right" style="margin-right: 10px">161          <a href="../genindex.html" title="General Index"162             accesskey="I">index</a></li>163        <li class="right" >164          <a href="../py-modindex.html" title="Python Module Index"165             >modules</a> |</li>166        <li class="right" >167          <a href="dis.html" title="dis — Disassembler for Python bytecode"168             accesskey="N">next</a> |</li>169        <li class="right" >170          <a href="py_compile.html" title="py_compile — Compile Python source files"171             accesskey="P">previous</a> |</li>172 173          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>174          <li><a href="https://www.python.org/">Python</a> &#187;</li>175          <li class="switchers">176            <div class="language_switcher_placeholder"></div>177            <div class="version_switcher_placeholder"></div>178          </li>179          <li>180              181          </li>182    <li id="cpython-language-and-version">183      <a href="../index.html">3.15.0a6 Documentation</a> &#187;184    </li>185 186          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>187          <li class="nav-item nav-item-2"><a href="language.html" accesskey="U">Python Language Services</a> &#187;</li>188        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code> — Byte-compile Python libraries</a></li>189                <li class="right">190                    191 192    <div class="inline-search" role="search">193        <form class="inline-search" action="../search.html" method="get">194          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">195          <input type="submit" value="Go">196        </form>197    </div>198                     |199                </li>200            <li class="right">201<label class="theme-selector-label">202    Theme203    <select class="theme-selector" oninput="activateTheme(this.value)">204        <option value="auto" selected>Auto</option>205        <option value="light">Light</option>206        <option value="dark">Dark</option>207    </select>208</label> |</li>209            210      </ul>211    </div>    212 213    <div class="document">214      <div class="documentwrapper">215        <div class="bodywrapper">216          <div class="body" role="main">217            218  <section id="module-compileall">219<span id="compileall-byte-compile-python-libraries"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code> — Byte-compile Python libraries<a class="headerlink" href="#module-compileall" title="Link to this heading">¶</a></h1>220<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/compileall.py">Lib/compileall.py</a></p>221<hr class="docutils" />222<p>This module provides some utility functions to support installing Python223libraries.  These functions compile Python source files in a directory tree.224This module can be used to create the cached byte-code files at library225installation time, which makes them available for use even by users who don’t226have write permission to the library directories.</p>227<div class="availability docutils container">228<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: not WASI.</p>229<p>This module does not work or is not available on WebAssembly. See230<a class="reference internal" href="intro.html#wasm-availability"><span class="std std-ref">WebAssembly platforms</span></a> for more information.</p>231</div>232<section id="command-line-use">233<span id="compileall-cli"></span><h2>Command-line use<a class="headerlink" href="#command-line-use" title="Link to this heading">¶</a></h2>234<p>This module can work as a script (using <strong class="program">python -m compileall</strong>) to235compile Python sources.</p>236<dl class="std option">237<dt class="sig sig-object std" id="cmdoption-compileall-arg-directory">238<span class="sig-name descname"><span class="pre">directory</span></span><span class="sig-prename descclassname"> <span class="pre">...</span></span><a class="headerlink" href="#cmdoption-compileall-arg-directory" title="Link to this definition">¶</a></dt>239<dt class="sig sig-object std" id="cmdoption-compileall-arg-file">240<span class="sig-name descname"><span class="pre">file</span></span><span class="sig-prename descclassname"> <span class="pre">...</span></span><a class="headerlink" href="#cmdoption-compileall-arg-file" title="Link to this definition">¶</a></dt>241<dd><p>Positional arguments are files to compile or directories that contain242source files, traversed recursively.  If no argument is given, behave as if243the command line was <code class="samp docutils literal notranslate"><span class="pre">-l</span> <em><span class="pre">&lt;directories</span> <span class="pre">from</span> <span class="pre">sys.path&gt;</span></em></code>.</p>244</dd></dl>245 246<dl class="std option">247<dt class="sig sig-object std" id="cmdoption-compileall-l">248<span class="sig-name descname"><span class="pre">-l</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-compileall-l" title="Link to this definition">¶</a></dt>249<dd><p>Do not recurse into subdirectories, only compile source code files directly250contained in the named or implied directories.</p>251</dd></dl>252 253<dl class="std option">254<dt class="sig sig-object std" id="cmdoption-compileall-f">255<span class="sig-name descname"><span class="pre">-f</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-compileall-f" title="Link to this definition">¶</a></dt>256<dd><p>Force rebuild even if timestamps are up-to-date.</p>257</dd></dl>258 259<dl class="std option">260<dt class="sig sig-object std" id="cmdoption-compileall-q">261<span class="sig-name descname"><span class="pre">-q</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-compileall-q" title="Link to this definition">¶</a></dt>262<dd><p>Do not print the list of files compiled. If passed once, error messages will263still be printed. If passed twice (<code class="docutils literal notranslate"><span class="pre">-qq</span></code>), all output is suppressed.</p>264</dd></dl>265 266<dl class="std option">267<dt class="sig sig-object std" id="cmdoption-compileall-d">268<span class="sig-name descname"><span class="pre">-d</span></span><span class="sig-prename descclassname"> <span class="pre">destdir</span></span><a class="headerlink" href="#cmdoption-compileall-d" title="Link to this definition">¶</a></dt>269<dd><p>Directory prepended to the path to each file being compiled.  This will270appear in compilation time tracebacks, and is also compiled in to the271byte-code file, where it will be used in tracebacks and other messages in272cases where the source file does not exist at the time the byte-code file is273executed.</p>274</dd></dl>275 276<dl class="std option">277<dt class="sig sig-object std" id="cmdoption-compileall-s">278<span class="sig-name descname"><span class="pre">-s</span></span><span class="sig-prename descclassname"> <span class="pre">strip_prefix</span></span><a class="headerlink" href="#cmdoption-compileall-s" title="Link to this definition">¶</a></dt>279<dd><p>Remove the given prefix from paths recorded in the <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files.280Paths are made relative to the prefix.</p>281<p>This option can be used with <code class="docutils literal notranslate"><span class="pre">-p</span></code> but not with <code class="docutils literal notranslate"><span class="pre">-d</span></code>.</p>282</dd></dl>283 284<dl class="std option">285<dt class="sig sig-object std" id="cmdoption-compileall-p">286<span class="sig-name descname"><span class="pre">-p</span></span><span class="sig-prename descclassname"> <span class="pre">prepend_prefix</span></span><a class="headerlink" href="#cmdoption-compileall-p" title="Link to this definition">¶</a></dt>287<dd><p>Prepend the given prefix to paths recorded in the <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files.288Use <code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">/</span></code> to make the paths absolute.</p>289<p>This option can be used with <code class="docutils literal notranslate"><span class="pre">-s</span></code> but not with <code class="docutils literal notranslate"><span class="pre">-d</span></code>.</p>290</dd></dl>291 292<dl class="std option">293<dt class="sig sig-object std" id="cmdoption-compileall-x">294<span class="sig-name descname"><span class="pre">-x</span></span><span class="sig-prename descclassname"> <span class="pre">regex</span></span><a class="headerlink" href="#cmdoption-compileall-x" title="Link to this definition">¶</a></dt>295<dd><p>regex is used to search the full path to each file considered for296compilation, and if the regex produces a match, the file is skipped.</p>297</dd></dl>298 299<dl class="std option">300<dt class="sig sig-object std" id="cmdoption-compileall-i">301<span class="sig-name descname"><span class="pre">-i</span></span><span class="sig-prename descclassname"> <span class="pre">list</span></span><a class="headerlink" href="#cmdoption-compileall-i" title="Link to this definition">¶</a></dt>302<dd><p>Read the file <code class="docutils literal notranslate"><span class="pre">list</span></code> and add each line that it contains to the list of303files and directories to compile.  If <code class="docutils literal notranslate"><span class="pre">list</span></code> is <code class="docutils literal notranslate"><span class="pre">-</span></code>, read lines from304<code class="docutils literal notranslate"><span class="pre">stdin</span></code>.</p>305</dd></dl>306 307<dl class="std option">308<dt class="sig sig-object std" id="cmdoption-compileall-b">309<span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-compileall-b" title="Link to this definition">¶</a></dt>310<dd><p>Write the byte-code files to their legacy locations and names, which may311overwrite byte-code files created by another version of Python.  The default312is to write files to their <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-3147/"><strong>PEP 3147</strong></a> locations and names, which allows313byte-code files from multiple versions of Python to coexist.</p>314</dd></dl>315 316<dl class="std option">317<dt class="sig sig-object std" id="cmdoption-compileall-r">318<span class="sig-name descname"><span class="pre">-r</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-compileall-r" title="Link to this definition">¶</a></dt>319<dd><p>Control the maximum recursion level for subdirectories.320If this is given, then <code class="docutils literal notranslate"><span class="pre">-l</span></code> option will not be taken into account.321<strong class="program">python -m compileall &lt;directory&gt; -r 0</strong> is equivalent to322<strong class="program">python -m compileall &lt;directory&gt; -l</strong>.</p>323</dd></dl>324 325<dl class="std option">326<dt class="sig sig-object std" id="cmdoption-compileall-j">327<span class="sig-name descname"><span class="pre">-j</span></span><span class="sig-prename descclassname"> <span class="pre">N</span></span><a class="headerlink" href="#cmdoption-compileall-j" title="Link to this definition">¶</a></dt>328<dd><p>Use <em>N</em> workers to compile the files within the given directory.329If <code class="docutils literal notranslate"><span class="pre">0</span></code> is used, then the result of <a class="reference internal" href="os.html#os.process_cpu_count" title="os.process_cpu_count"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.process_cpu_count()</span></code></a>330will be used.</p>331</dd></dl>332 333<dl class="std option">334<dt class="sig sig-object std" id="cmdoption-compileall-invalidation-mode">335<span class="sig-name descname"><span class="pre">--invalidation-mode</span></span><span class="sig-prename descclassname"> <span class="pre">[timestamp|checked-hash|unchecked-hash]</span></span><a class="headerlink" href="#cmdoption-compileall-invalidation-mode" title="Link to this definition">¶</a></dt>336<dd><p>Control how the generated byte-code files are invalidated at runtime.337The <code class="docutils literal notranslate"><span class="pre">timestamp</span></code> value, means that <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files with the source timestamp338and size embedded will be generated. The <code class="docutils literal notranslate"><span class="pre">checked-hash</span></code> and339<code class="docutils literal notranslate"><span class="pre">unchecked-hash</span></code> values cause hash-based pycs to be generated. Hash-based340pycs embed a hash of the source file contents rather than a timestamp. See341<a class="reference internal" href="../reference/import.html#pyc-invalidation"><span class="std std-ref">Cached bytecode invalidation</span></a> for more information on how Python validates342bytecode cache files at runtime.343The default is <code class="docutils literal notranslate"><span class="pre">timestamp</span></code> if the <span class="target" id="index-1"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">SOURCE_DATE_EPOCH</span></code> environment344variable is not set, and <code class="docutils literal notranslate"><span class="pre">checked-hash</span></code> if the <code class="docutils literal notranslate"><span class="pre">SOURCE_DATE_EPOCH</span></code>345environment variable is set.</p>346</dd></dl>347 348<dl class="std option">349<dt class="sig sig-object std" id="cmdoption-compileall-o">350<span class="sig-name descname"><span class="pre">-o</span></span><span class="sig-prename descclassname"> <span class="pre">level</span></span><a class="headerlink" href="#cmdoption-compileall-o" title="Link to this definition">¶</a></dt>351<dd><p>Compile with the given optimization level. May be used multiple times352to compile for multiple levels at a time (for example,353<code class="docutils literal notranslate"><span class="pre">compileall</span> <span class="pre">-o</span> <span class="pre">1</span> <span class="pre">-o</span> <span class="pre">2</span></code>).</p>354</dd></dl>355 356<dl class="std option">357<dt class="sig sig-object std" id="cmdoption-compileall-e">358<span class="sig-name descname"><span class="pre">-e</span></span><span class="sig-prename descclassname"> <span class="pre">dir</span></span><a class="headerlink" href="#cmdoption-compileall-e" title="Link to this definition">¶</a></dt>359<dd><p>Ignore symlinks pointing outside the given directory.</p>360</dd></dl>361 362<dl class="std option">363<dt class="sig sig-object std" id="cmdoption-compileall-hardlink-dupes">364<span class="sig-name descname"><span class="pre">--hardlink-dupes</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-compileall-hardlink-dupes" title="Link to this definition">¶</a></dt>365<dd><p>If two <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files with different optimization level have366the same content, use hard links to consolidate duplicate files.</p>367</dd></dl>368 369<div class="versionchanged">370<p><span class="versionmodified changed">Changed in version 3.2: </span>Added the <code class="docutils literal notranslate"><span class="pre">-i</span></code>, <code class="docutils literal notranslate"><span class="pre">-b</span></code> and <code class="docutils literal notranslate"><span class="pre">-h</span></code> options.</p>371</div>372<div class="versionchanged">373<p><span class="versionmodified changed">Changed in version 3.5: </span>Added the  <code class="docutils literal notranslate"><span class="pre">-j</span></code>, <code class="docutils literal notranslate"><span class="pre">-r</span></code>, and <code class="docutils literal notranslate"><span class="pre">-qq</span></code> options.  <code class="docutils literal notranslate"><span class="pre">-q</span></code> option374was changed to a multilevel value.  <code class="docutils literal notranslate"><span class="pre">-b</span></code> will always produce a375byte-code file ending in <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>, never <code class="docutils literal notranslate"><span class="pre">.pyo</span></code>.</p>376</div>377<div class="versionchanged">378<p><span class="versionmodified changed">Changed in version 3.7: </span>Added the <code class="docutils literal notranslate"><span class="pre">--invalidation-mode</span></code> option.</p>379</div>380<div class="versionchanged">381<p><span class="versionmodified changed">Changed in version 3.9: </span>Added the <code class="docutils literal notranslate"><span class="pre">-s</span></code>, <code class="docutils literal notranslate"><span class="pre">-p</span></code>, <code class="docutils literal notranslate"><span class="pre">-e</span></code> and <code class="docutils literal notranslate"><span class="pre">--hardlink-dupes</span></code> options.382Raised the default recursion limit from 10 to383<a class="reference internal" href="sys.html#sys.getrecursionlimit" title="sys.getrecursionlimit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getrecursionlimit()</span></code></a>.384Added the possibility to specify the <code class="docutils literal notranslate"><span class="pre">-o</span></code> option multiple times.</p>385</div>386<p>There is no command-line option to control the optimization level used by the387<a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> function, because the Python interpreter itself already388provides the option: <strong class="program">python -O -m compileall</strong>.</p>389<p>Similarly, the <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> function respects the <a class="reference internal" href="sys.html#sys.pycache_prefix" title="sys.pycache_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.pycache_prefix</span></code></a>390setting. The generated bytecode cache will only be useful if <code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code> is391run with the same <code class="xref py py-data docutils literal notranslate"><span class="pre">sys.pycache_prefix</span></code> (if any) that will be used at392runtime.</p>393</section>394<section id="public-functions">395<h2>Public functions<a class="headerlink" href="#public-functions" title="Link to this heading">¶</a></h2>396<dl class="py function">397<dt class="sig sig-object py" id="compileall.compile_dir">398<span class="sig-prename descclassname"><span class="pre">compileall.</span></span><span class="sig-name descname"><span class="pre">compile_dir</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dir</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxlevels</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">sys.getrecursionlimit()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ddir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rx</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quiet</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legacy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optimize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">workers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">invalidation_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">stripdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prependdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">limit_sl_dest</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hardlink_dupes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#compileall.compile_dir" title="Link to this definition">¶</a></dt>399<dd><p>Recursively descend the directory tree named by <em>dir</em>, compiling all <code class="file docutils literal notranslate"><span class="pre">.py</span></code>400files along the way. Return a true value if all the files compiled successfully,401and a false value otherwise.</p>402<p>The <em>maxlevels</em> parameter is used to limit the depth of the recursion; it403defaults to <code class="docutils literal notranslate"><span class="pre">sys.getrecursionlimit()</span></code>.</p>404<p>If <em>ddir</em> is given, it is prepended to the path to each file being compiled405for use in compilation time tracebacks, and is also compiled in to the406byte-code file, where it will be used in tracebacks and other messages in407cases where the source file does not exist at the time the byte-code file is408executed.</p>409<p>If <em>force</em> is true, modules are re-compiled even if the timestamps are up to410date.</p>411<p>If <em>rx</em> is given, its <code class="docutils literal notranslate"><span class="pre">search</span></code> method is called on the complete path to each412file considered for compilation, and if it returns a true value, the file413is skipped. This can be used to exclude files matching a regular expression,414given as a <a class="reference internal" href="re.html#re-objects"><span class="std std-ref">re.Pattern</span></a> object.</p>415<p>If <em>quiet</em> is <code class="docutils literal notranslate"><span class="pre">False</span></code> or <code class="docutils literal notranslate"><span class="pre">0</span></code> (the default), the filenames and other416information are printed to standard out. Set to <code class="docutils literal notranslate"><span class="pre">1</span></code>, only errors are417printed. Set to <code class="docutils literal notranslate"><span class="pre">2</span></code>, all output is suppressed.</p>418<p>If <em>legacy</em> is true, byte-code files are written to their legacy locations419and names, which may overwrite byte-code files created by another version of420Python.  The default is to write files to their <span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-3147/"><strong>PEP 3147</strong></a> locations and421names, which allows byte-code files from multiple versions of Python to422coexist.</p>423<p><em>optimize</em> specifies the optimization level for the compiler.  It is passed to424the built-in <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> function. Accepts also a sequence of optimization425levels which lead to multiple compilations of one <code class="file docutils literal notranslate"><span class="pre">.py</span></code> file in one call.</p>426<p>The argument <em>workers</em> specifies how many workers are used to427compile files in parallel. The default is to not use multiple workers.428If the platform can’t use multiple workers and <em>workers</em> argument is given,429then sequential compilation will be used as a fallback.  If <em>workers</em>430is 0, the number of cores in the system is used.  If <em>workers</em> is431lower than <code class="docutils literal notranslate"><span class="pre">0</span></code>, a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> will be raised.</p>432<p><em>invalidation_mode</em> should be a member of the433<a class="reference internal" href="py_compile.html#py_compile.PycInvalidationMode" title="py_compile.PycInvalidationMode"><code class="xref py py-class docutils literal notranslate"><span class="pre">py_compile.PycInvalidationMode</span></code></a> enum and controls how the generated434pycs are invalidated at runtime.</p>435<p>The <em>stripdir</em>, <em>prependdir</em> and <em>limit_sl_dest</em> arguments correspond to436the <code class="docutils literal notranslate"><span class="pre">-s</span></code>, <code class="docutils literal notranslate"><span class="pre">-p</span></code> and <code class="docutils literal notranslate"><span class="pre">-e</span></code> options described above.437They may be specified as <code class="docutils literal notranslate"><span class="pre">str</span></code> or <a class="reference internal" href="os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a>.</p>438<p>If <em>hardlink_dupes</em> is true and two <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files with different optimization439level have the same content, use hard links to consolidate duplicate files.</p>440<div class="versionchanged">441<p><span class="versionmodified changed">Changed in version 3.2: </span>Added the <em>legacy</em> and <em>optimize</em> parameter.</p>442</div>443<div class="versionchanged">444<p><span class="versionmodified changed">Changed in version 3.5: </span>Added the <em>workers</em> parameter.</p>445</div>446<div class="versionchanged">447<p><span class="versionmodified changed">Changed in version 3.5: </span><em>quiet</em> parameter was changed to a multilevel value.</p>448</div>449<div class="versionchanged">450<p><span class="versionmodified changed">Changed in version 3.5: </span>The <em>legacy</em> parameter only writes out <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files, not <code class="docutils literal notranslate"><span class="pre">.pyo</span></code> files451no matter what the value of <em>optimize</em> is.</p>452</div>453<div class="versionchanged">454<p><span class="versionmodified changed">Changed in version 3.6: </span>Accepts a <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.</p>455</div>456<div class="versionchanged">457<p><span class="versionmodified changed">Changed in version 3.7: </span>The <em>invalidation_mode</em> parameter was added.</p>458</div>459<div class="versionchanged">460<p><span class="versionmodified changed">Changed in version 3.7.2: </span>The <em>invalidation_mode</em> parameter’s default value is updated to <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>461</div>462<div class="versionchanged">463<p><span class="versionmodified changed">Changed in version 3.8: </span>Setting <em>workers</em> to 0 now chooses the optimal number of cores.</p>464</div>465<div class="versionchanged">466<p><span class="versionmodified changed">Changed in version 3.9: </span>Added <em>stripdir</em>, <em>prependdir</em>, <em>limit_sl_dest</em> and <em>hardlink_dupes</em> arguments.467Default value of <em>maxlevels</em> was changed from <code class="docutils literal notranslate"><span class="pre">10</span></code> to <code class="docutils literal notranslate"><span class="pre">sys.getrecursionlimit()</span></code></p>468</div>469</dd></dl>470 471<dl class="py function">472<dt class="sig sig-object py" id="compileall.compile_file">473<span class="sig-prename descclassname"><span class="pre">compileall.</span></span><span class="sig-name descname"><span class="pre">compile_file</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fullname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ddir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rx</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quiet</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legacy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optimize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">invalidation_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">stripdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prependdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">limit_sl_dest</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hardlink_dupes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#compileall.compile_file" title="Link to this definition">¶</a></dt>474<dd><p>Compile the file with path <em>fullname</em>. Return a true value if the file475compiled successfully, and a false value otherwise.</p>476<p>If <em>ddir</em> is given, it is prepended to the path to the file being compiled477for use in compilation time tracebacks, and is also compiled in to the478byte-code file, where it will be used in tracebacks and other messages in479cases where the source file does not exist at the time the byte-code file is480executed.</p>481<p>If <em>rx</em> is given, its <code class="docutils literal notranslate"><span class="pre">search</span></code> method is passed the full path name to the482file being compiled, and if it returns a true value, the file is not483compiled and <code class="docutils literal notranslate"><span class="pre">True</span></code> is returned. This can be used to exclude files matching484a regular expression, given as a <a class="reference internal" href="re.html#re-objects"><span class="std std-ref">re.Pattern</span></a> object.</p>485<p>If <em>quiet</em> is <code class="docutils literal notranslate"><span class="pre">False</span></code> or <code class="docutils literal notranslate"><span class="pre">0</span></code> (the default), the filenames and other486information are printed to standard out. Set to <code class="docutils literal notranslate"><span class="pre">1</span></code>, only errors are487printed. Set to <code class="docutils literal notranslate"><span class="pre">2</span></code>, all output is suppressed.</p>488<p>If <em>legacy</em> is true, byte-code files are written to their legacy locations489and names, which may overwrite byte-code files created by another version of490Python.  The default is to write files to their <span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-3147/"><strong>PEP 3147</strong></a> locations and491names, which allows byte-code files from multiple versions of Python to492coexist.</p>493<p><em>optimize</em> specifies the optimization level for the compiler.  It is passed to494the built-in <a class="reference internal" href="functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a> function. Accepts also a sequence of optimization495levels which lead to multiple compilations of one <code class="file docutils literal notranslate"><span class="pre">.py</span></code> file in one call.</p>496<p><em>invalidation_mode</em> should be a member of the497<a class="reference internal" href="py_compile.html#py_compile.PycInvalidationMode" title="py_compile.PycInvalidationMode"><code class="xref py py-class docutils literal notranslate"><span class="pre">py_compile.PycInvalidationMode</span></code></a> enum and controls how the generated498pycs are invalidated at runtime.</p>499<p>The <em>stripdir</em>, <em>prependdir</em> and <em>limit_sl_dest</em> arguments correspond to500the <code class="docutils literal notranslate"><span class="pre">-s</span></code>, <code class="docutils literal notranslate"><span class="pre">-p</span></code> and <code class="docutils literal notranslate"><span class="pre">-e</span></code> options described above.501They may be specified as <code class="docutils literal notranslate"><span class="pre">str</span></code> or <a class="reference internal" href="os.html#os.PathLike" title="os.PathLike"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a>.</p>502<p>If <em>hardlink_dupes</em> is true and two <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files with different optimization503level have the same content, use hard links to consolidate duplicate files.</p>504<div class="versionadded">505<p><span class="versionmodified added">Added in version 3.2.</span></p>506</div>507<div class="versionchanged">508<p><span class="versionmodified changed">Changed in version 3.5: </span><em>quiet</em> parameter was changed to a multilevel value.</p>509</div>510<div class="versionchanged">511<p><span class="versionmodified changed">Changed in version 3.5: </span>The <em>legacy</em> parameter only writes out <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files, not <code class="docutils literal notranslate"><span class="pre">.pyo</span></code> files512no matter what the value of <em>optimize</em> is.</p>513</div>514<div class="versionchanged">515<p><span class="versionmodified changed">Changed in version 3.7: </span>The <em>invalidation_mode</em> parameter was added.</p>516</div>517<div class="versionchanged">518<p><span class="versionmodified changed">Changed in version 3.7.2: </span>The <em>invalidation_mode</em> parameter’s default value is updated to <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>519</div>520<div class="versionchanged">521<p><span class="versionmodified changed">Changed in version 3.9: </span>Added <em>stripdir</em>, <em>prependdir</em>, <em>limit_sl_dest</em> and <em>hardlink_dupes</em> arguments.</p>522</div>523</dd></dl>524 525<dl class="py function">526<dt class="sig sig-object py" id="compileall.compile_path">527<span class="sig-prename descclassname"><span class="pre">compileall.</span></span><span class="sig-name descname"><span class="pre">compile_path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">skip_curdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxlevels</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">force</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">quiet</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">legacy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optimize</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">invalidation_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#compileall.compile_path" title="Link to this definition">¶</a></dt>528<dd><p>Byte-compile all the <code class="file docutils literal notranslate"><span class="pre">.py</span></code> files found along <code class="docutils literal notranslate"><span class="pre">sys.path</span></code>. Return a529true value if all the files compiled successfully, and a false value otherwise.</p>530<p>If <em>skip_curdir</em> is true (the default), the current directory is not included531in the search.  All other parameters are passed to the <a class="reference internal" href="#compileall.compile_dir" title="compileall.compile_dir"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile_dir()</span></code></a>532function.  Note that unlike the other compile functions, <code class="docutils literal notranslate"><span class="pre">maxlevels</span></code>533defaults to <code class="docutils literal notranslate"><span class="pre">0</span></code>.</p>534<div class="versionchanged">535<p><span class="versionmodified changed">Changed in version 3.2: </span>Added the <em>legacy</em> and <em>optimize</em> parameter.</p>536</div>537<div class="versionchanged">538<p><span class="versionmodified changed">Changed in version 3.5: </span><em>quiet</em> parameter was changed to a multilevel value.</p>539</div>540<div class="versionchanged">541<p><span class="versionmodified changed">Changed in version 3.5: </span>The <em>legacy</em> parameter only writes out <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files, not <code class="docutils literal notranslate"><span class="pre">.pyo</span></code> files542no matter what the value of <em>optimize</em> is.</p>543</div>544<div class="versionchanged">545<p><span class="versionmodified changed">Changed in version 3.7: </span>The <em>invalidation_mode</em> parameter was added.</p>546</div>547<div class="versionchanged">548<p><span class="versionmodified changed">Changed in version 3.7.2: </span>The <em>invalidation_mode</em> parameter’s default value is updated to <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>549</div>550</dd></dl>551 552<p>To force a recompile of all the <code class="file docutils literal notranslate"><span class="pre">.py</span></code> files in the <code class="file docutils literal notranslate"><span class="pre">Lib/</span></code>553subdirectory and all its subdirectories:</p>554<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">compileall</span>555 556<span class="n">compileall</span><span class="o">.</span><span class="n">compile_dir</span><span class="p">(</span><span class="s1">&#39;Lib/&#39;</span><span class="p">,</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>557 558<span class="c1"># Perform same compilation, excluding files in .svn directories.</span>559<span class="kn">import</span><span class="w"> </span><span class="nn">re</span>560<span class="n">compileall</span><span class="o">.</span><span class="n">compile_dir</span><span class="p">(</span><span class="s1">&#39;Lib/&#39;</span><span class="p">,</span> <span class="n">rx</span><span class="o">=</span><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;[/</span><span class="se">\\</span><span class="s1">][.]svn&#39;</span><span class="p">),</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>561 562<span class="c1"># pathlib.Path objects can also be used.</span>563<span class="kn">import</span><span class="w"> </span><span class="nn">pathlib</span>564<span class="n">compileall</span><span class="o">.</span><span class="n">compile_dir</span><span class="p">(</span><span class="n">pathlib</span><span class="o">.</span><span class="n">Path</span><span class="p">(</span><span class="s1">&#39;Lib/&#39;</span><span class="p">),</span> <span class="n">force</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>565</pre></div>566</div>567<div class="admonition seealso">568<p class="admonition-title">See also</p>569<dl class="simple">570<dt>Module <a class="reference internal" href="py_compile.html#module-py_compile" title="py_compile: Generate byte-code files from Python source files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">py_compile</span></code></a></dt><dd><p>Byte-compile a single source file.</p>571</dd>572</dl>573</div>574</section>575</section>576 577 578            <div class="clearer"></div>579          </div>580        </div>581      </div>582      <div class="sphinxsidebar" role="navigation" aria-label="Main">583        <div class="sphinxsidebarwrapper">584  <div>585    <h3><a href="../contents.html">Table of Contents</a></h3>586    <ul>587<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code> — Byte-compile Python libraries</a><ul>588<li><a class="reference internal" href="#command-line-use">Command-line use</a></li>589<li><a class="reference internal" href="#public-functions">Public functions</a></li>590</ul>591</li>592</ul>593 594  </div>595  <div>596    <h4>Previous topic</h4>597    <p class="topless"><a href="py_compile.html"598                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">py_compile</span></code> — Compile Python source files</a></p>599  </div>600  <div>601    <h4>Next topic</h4>602    <p class="topless"><a href="dis.html"603                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dis</span></code> — Disassembler for Python bytecode</a></p>604  </div>605  <script>606    document.addEventListener('DOMContentLoaded', () => {607        const title = document.querySelector('meta[property="og:title"]').content;608        const elements = document.querySelectorAll('.improvepage');609        const pageurl = window.location.href.split('?')[0];610        elements.forEach(element => {611            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));612            url.searchParams.set('pagetitle', title);613            url.searchParams.set('pageurl', pageurl);614            url.searchParams.set('pagesource', "library/compileall.rst");615            element.href = url.toString();616        });617    });618  </script>619  <div role="note" aria-label="source link">620    <h3>This page</h3>621    <ul class="this-page-menu">622      <li><a href="../bugs.html">Report a bug</a></li>623      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>624      <li>625        <a href="https://github.com/python/cpython/blob/main/Doc/library/compileall.rst?plain=1"626            rel="nofollow">Show source627        </a>628      </li>629      630    </ul>631  </div>632        </div>633<div id="sidebarbutton" title="Collapse sidebar">634<span>«</span>635</div>636 637      </div>638      <div class="clearer"></div>639    </div>  640    <div class="related" role="navigation" aria-label="Related">641      <h3>Navigation</h3>642      <ul>643        <li class="right" style="margin-right: 10px">644          <a href="../genindex.html" title="General Index"645             >index</a></li>646        <li class="right" >647          <a href="../py-modindex.html" title="Python Module Index"648             >modules</a> |</li>649        <li class="right" >650          <a href="dis.html" title="dis — Disassembler for Python bytecode"651             >next</a> |</li>652        <li class="right" >653          <a href="py_compile.html" title="py_compile — Compile Python source files"654             >previous</a> |</li>655 656          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>657          <li><a href="https://www.python.org/">Python</a> &#187;</li>658          <li class="switchers">659            <div class="language_switcher_placeholder"></div>660            <div class="version_switcher_placeholder"></div>661          </li>662          <li>663              664          </li>665    <li id="cpython-language-and-version">666      <a href="../index.html">3.15.0a6 Documentation</a> &#187;667    </li>668 669          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>670          <li class="nav-item nav-item-2"><a href="language.html" >Python Language Services</a> &#187;</li>671        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code> — Byte-compile Python libraries</a></li>672                <li class="right">673                    674 675    <div class="inline-search" role="search">676        <form class="inline-search" action="../search.html" method="get">677          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">678          <input type="submit" value="Go">679        </form>680    </div>681                     |682                </li>683            <li class="right">684<label class="theme-selector-label">685    Theme686    <select class="theme-selector" oninput="activateTheme(this.value)">687        <option value="auto" selected>Auto</option>688        <option value="light">Light</option>689        <option value="dark">Dark</option>690    </select>691</label> |</li>692            693      </ul>694    </div>  695    <div class="footer">696    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.697    <br>698    This page is licensed under the Python Software Foundation License Version 2.699    <br>700    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.701    <br>702    703      See <a href="/license.html">History and License</a> for more information.<br>704    705    706    <br>707 708    The Python Software Foundation is a non-profit corporation.709<a href="https://www.python.org/psf/donations/">Please donate.</a>710<br>711    <br>712      Last updated on Mar 10, 2026 (08:58 UTC).713    714      <a href="/bugs.html">Found a bug</a>?715    716    <br>717 718    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.719    </div>720 721  </body>722</html>