Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
compression.html361 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="The compression package" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/compression.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="The compression package contains the canonical compression modules containing interfaces to several different compression algorithms. Some of these modules have historically been available as separ..." />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_compression_ae35af9e.png" />15<meta property="og:image:alt" content="The compression package contains the canonical compression modules containing interfaces to several different compression algorithms. Some of these modules have historically been available as separ..." />16<meta name="description" content="The compression package contains the canonical compression modules containing interfaces to several different compression algorithms. Some of these modules have historically been available as separ..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>The compression package &#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="compression.zstd — Compression compatible with the Zstandard format" href="compression.zstd.html" />43    <link rel="prev" title="Data Compression and Archiving" href="archiving.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/compression.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    <h4>Previous topic</h4>106    <p class="topless"><a href="archiving.html"107                          title="previous chapter">Data Compression and Archiving</a></p>108  </div>109  <div>110    <h4>Next topic</h4>111    <p class="topless"><a href="compression.zstd.html"112                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.zstd</span></code> — Compression compatible with the Zstandard format</a></p>113  </div>114  <script>115    document.addEventListener('DOMContentLoaded', () => {116        const title = document.querySelector('meta[property="og:title"]').content;117        const elements = document.querySelectorAll('.improvepage');118        const pageurl = window.location.href.split('?')[0];119        elements.forEach(element => {120            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));121            url.searchParams.set('pagetitle', title);122            url.searchParams.set('pageurl', pageurl);123            url.searchParams.set('pagesource', "library/compression.rst");124            element.href = url.toString();125        });126    });127  </script>128  <div role="note" aria-label="source link">129    <h3>This page</h3>130    <ul class="this-page-menu">131      <li><a href="../bugs.html">Report a bug</a></li>132      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>133      <li>134        <a href="https://github.com/python/cpython/blob/main/Doc/library/compression.rst?plain=1"135            rel="nofollow">Show source136        </a>137      </li>138      139    </ul>140  </div>141        </nav>142    </div>143</div>144 145  146    <div class="related" role="navigation" aria-label="Related">147      <h3>Navigation</h3>148      <ul>149        <li class="right" style="margin-right: 10px">150          <a href="../genindex.html" title="General Index"151             accesskey="I">index</a></li>152        <li class="right" >153          <a href="../py-modindex.html" title="Python Module Index"154             >modules</a> |</li>155        <li class="right" >156          <a href="compression.zstd.html" title="compression.zstd — Compression compatible with the Zstandard format"157             accesskey="N">next</a> |</li>158        <li class="right" >159          <a href="archiving.html" title="Data Compression and Archiving"160             accesskey="P">previous</a> |</li>161 162          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>163          <li><a href="https://www.python.org/">Python</a> &#187;</li>164          <li class="switchers">165            <div class="language_switcher_placeholder"></div>166            <div class="version_switcher_placeholder"></div>167          </li>168          <li>169              170          </li>171    <li id="cpython-language-and-version">172      <a href="../index.html">3.15.0a6 Documentation</a> &#187;173    </li>174 175          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>176          <li class="nav-item nav-item-2"><a href="archiving.html" accesskey="U">Data Compression and Archiving</a> &#187;</li>177        <li class="nav-item nav-item-this"><a href="">The <code class="xref py py-mod docutils literal notranslate"><span class="pre">compression</span></code> package</a></li>178                <li class="right">179                    180 181    <div class="inline-search" role="search">182        <form class="inline-search" action="../search.html" method="get">183          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">184          <input type="submit" value="Go">185        </form>186    </div>187                     |188                </li>189            <li class="right">190<label class="theme-selector-label">191    Theme192    <select class="theme-selector" oninput="activateTheme(this.value)">193        <option value="auto" selected>Auto</option>194        <option value="light">Light</option>195        <option value="dark">Dark</option>196    </select>197</label> |</li>198            199      </ul>200    </div>    201 202    <div class="document">203      <div class="documentwrapper">204        <div class="bodywrapper">205          <div class="body" role="main">206            207  <section id="module-compression">208<span id="the-compression-package"></span><h1>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">compression</span></code> package<a class="headerlink" href="#module-compression" title="Link to this heading">¶</a></h1>209<div class="versionadded">210<p><span class="versionmodified added">Added in version 3.14.</span></p>211</div>212<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">compression</span></code> package contains the canonical compression modules213containing interfaces to several different compression algorithms. Some of214these modules have historically been available as separate modules; those will215continue to be available under their original names for compatibility reasons,216and will not be removed without a deprecation cycle. The use of modules in217<code class="xref py py-mod docutils literal notranslate"><span class="pre">compression</span></code> is encouraged where practical.</p>218<ul class="simple">219<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.bz2</span></code> – Re-exports <a class="reference internal" href="bz2.html#module-bz2" title="bz2: Interfaces for bzip2 compression and decompression."><code class="xref py py-mod docutils literal notranslate"><span class="pre">bz2</span></code></a></p></li>220<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.gzip</span></code> – Re-exports <a class="reference internal" href="gzip.html#module-gzip" title="gzip: Interfaces for gzip compression and decompression using file objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code></a></p></li>221<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.lzma</span></code> – Re-exports <a class="reference internal" href="lzma.html#module-lzma" title="lzma: A Python wrapper for the liblzma compression library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">lzma</span></code></a></p></li>222<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.zlib</span></code> – Re-exports <a class="reference internal" href="zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a></p></li>223<li><p><a class="reference internal" href="compression.zstd.html#module-compression.zstd" title="compression.zstd: Low-level interface to compression and decompression routines in the zstd library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.zstd</span></code></a> – Wrapper for the Zstandard compression library</p></li>224</ul>225</section>226 227 228            <div class="clearer"></div>229          </div>230        </div>231      </div>232      <div class="sphinxsidebar" role="navigation" aria-label="Main">233        <div class="sphinxsidebarwrapper">234  <div>235    <h4>Previous topic</h4>236    <p class="topless"><a href="archiving.html"237                          title="previous chapter">Data Compression and Archiving</a></p>238  </div>239  <div>240    <h4>Next topic</h4>241    <p class="topless"><a href="compression.zstd.html"242                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">compression.zstd</span></code> — Compression compatible with the Zstandard format</a></p>243  </div>244  <script>245    document.addEventListener('DOMContentLoaded', () => {246        const title = document.querySelector('meta[property="og:title"]').content;247        const elements = document.querySelectorAll('.improvepage');248        const pageurl = window.location.href.split('?')[0];249        elements.forEach(element => {250            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));251            url.searchParams.set('pagetitle', title);252            url.searchParams.set('pageurl', pageurl);253            url.searchParams.set('pagesource', "library/compression.rst");254            element.href = url.toString();255        });256    });257  </script>258  <div role="note" aria-label="source link">259    <h3>This page</h3>260    <ul class="this-page-menu">261      <li><a href="../bugs.html">Report a bug</a></li>262      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>263      <li>264        <a href="https://github.com/python/cpython/blob/main/Doc/library/compression.rst?plain=1"265            rel="nofollow">Show source266        </a>267      </li>268      269    </ul>270  </div>271        </div>272<div id="sidebarbutton" title="Collapse sidebar">273<span>«</span>274</div>275 276      </div>277      <div class="clearer"></div>278    </div>  279    <div class="related" role="navigation" aria-label="Related">280      <h3>Navigation</h3>281      <ul>282        <li class="right" style="margin-right: 10px">283          <a href="../genindex.html" title="General Index"284             >index</a></li>285        <li class="right" >286          <a href="../py-modindex.html" title="Python Module Index"287             >modules</a> |</li>288        <li class="right" >289          <a href="compression.zstd.html" title="compression.zstd — Compression compatible with the Zstandard format"290             >next</a> |</li>291        <li class="right" >292          <a href="archiving.html" title="Data Compression and Archiving"293             >previous</a> |</li>294 295          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>296          <li><a href="https://www.python.org/">Python</a> &#187;</li>297          <li class="switchers">298            <div class="language_switcher_placeholder"></div>299            <div class="version_switcher_placeholder"></div>300          </li>301          <li>302              303          </li>304    <li id="cpython-language-and-version">305      <a href="../index.html">3.15.0a6 Documentation</a> &#187;306    </li>307 308          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>309          <li class="nav-item nav-item-2"><a href="archiving.html" >Data Compression and Archiving</a> &#187;</li>310        <li class="nav-item nav-item-this"><a href="">The <code class="xref py py-mod docutils literal notranslate"><span class="pre">compression</span></code> package</a></li>311                <li class="right">312                    313 314    <div class="inline-search" role="search">315        <form class="inline-search" action="../search.html" method="get">316          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">317          <input type="submit" value="Go">318        </form>319    </div>320                     |321                </li>322            <li class="right">323<label class="theme-selector-label">324    Theme325    <select class="theme-selector" oninput="activateTheme(this.value)">326        <option value="auto" selected>Auto</option>327        <option value="light">Light</option>328        <option value="dark">Dark</option>329    </select>330</label> |</li>331            332      </ul>333    </div>  334    <div class="footer">335    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.336    <br>337    This page is licensed under the Python Software Foundation License Version 2.338    <br>339    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.340    <br>341    342      See <a href="/license.html">History and License</a> for more information.<br>343    344    345    <br>346 347    The Python Software Foundation is a non-profit corporation.348<a href="https://www.python.org/psf/donations/">Please donate.</a>349<br>350    <br>351      Last updated on Mar 10, 2026 (08:58 UTC).352    353      <a href="/bugs.html">Found a bug</a>?354    355    <br>356 357    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.358    </div>359 360  </body>361</html>