parthtamu/rag-code-assistant
0
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="sys — System-specific parameters and functions" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/sys.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available. Unless explicitly noted oth..." />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_sys_18eb6fe4.png" />15<meta property="og:image:alt" content="This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available. Unless explicitly noted oth..." />16<meta name="description" content="This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available. Unless explicitly noted oth..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20 <title>sys — System-specific parameters and functions — 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="sys.monitoring — Execution event monitoring" href="sys.monitoring.html" />43 <link rel="prev" title="Python Runtime Services" href="python.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/sys.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="python.html"107 title="previous chapter">Python Runtime Services</a></p>108 </div>109 <div>110 <h4>Next topic</h4>111 <p class="topless"><a href="sys.monitoring.html"112 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys.monitoring</span></code> — Execution event monitoring</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/sys.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/sys.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="sys.monitoring.html" title="sys.monitoring — Execution event monitoring"157 accesskey="N">next</a> |</li>158 <li class="right" >159 <a href="python.html" title="Python Runtime Services"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> »</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> »173 </li>174 175 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>176 <li class="nav-item nav-item-2"><a href="python.html" accesskey="U">Python Runtime Services</a> »</li>177 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code> — System-specific parameters and functions</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-sys">208<span id="sys-system-specific-parameters-and-functions"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code> — System-specific parameters and functions<a class="headerlink" href="#module-sys" title="Link to this heading">¶</a></h1>209<hr class="docutils" />210<p>This module provides access to some variables used or maintained by the211interpreter and to functions that interact strongly with the interpreter. It is212always available. Unless explicitly noted otherwise, all variables are read-only.</p>213<dl class="py data">214<dt class="sig sig-object py" id="sys.abi_info">215<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">abi_info</span></span><a class="headerlink" href="#sys.abi_info" title="Link to this definition">¶</a></dt>216<dd><div class="versionadded">217<p><span class="versionmodified added">Added in version 3.15.</span></p>218</div>219<p>An object containing information about the ABI of the currently running220Python interpreter.221It should include information that affect the CPython ABI in ways that222require a specific build of the interpreter chosen from variants that can223co-exist on a single machine.224For example, it does not encode the base OS (Linux or Windows), but does225include pointer size since some systems support both 32- and 64-bit builds.226The available entries are the same on all platforms;227e.g. <em>pointer_size</em> is available even on 64-bit-only architectures.</p>228<p>The following attributes are available:</p>229<dl class="py attribute">230<dt class="sig sig-object py" id="sys.abi_info.pointer_bits">231<span class="sig-prename descclassname"><span class="pre">abi_info.</span></span><span class="sig-name descname"><span class="pre">pointer_bits</span></span><a class="headerlink" href="#sys.abi_info.pointer_bits" title="Link to this definition">¶</a></dt>232<dd><p>The width of pointers in bits, as an integer,233equivalent to <code class="docutils literal notranslate"><span class="pre">8</span> <span class="pre">*</span> <span class="pre">sizeof(void</span> <span class="pre">*)</span></code>.234Usually, this is <code class="docutils literal notranslate"><span class="pre">32</span></code> or <code class="docutils literal notranslate"><span class="pre">64</span></code>.</p>235</dd></dl>236 237<dl class="py attribute">238<dt class="sig sig-object py" id="sys.abi_info.free_threaded">239<span class="sig-prename descclassname"><span class="pre">abi_info.</span></span><span class="sig-name descname"><span class="pre">free_threaded</span></span><a class="headerlink" href="#sys.abi_info.free_threaded" title="Link to this definition">¶</a></dt>240<dd><p>A Boolean indicating whether the interpreter was built with241<a class="reference internal" href="../glossary.html#term-free-threading"><span class="xref std std-term">free threading</span></a> support.242This reflects either the presence of the <a class="reference internal" href="../using/configure.html#cmdoption-disable-gil"><code class="xref std std-option docutils literal notranslate"><span class="pre">--disable-gil</span></code></a>243<code class="file docutils literal notranslate"><span class="pre">configure</span></code> option (on Unix)244or setting the <code class="docutils literal notranslate"><span class="pre">DisableGil</span></code> property (on Windows).</p>245</dd></dl>246 247<dl class="py attribute">248<dt class="sig sig-object py" id="sys.abi_info.debug">249<span class="sig-prename descclassname"><span class="pre">abi_info.</span></span><span class="sig-name descname"><span class="pre">debug</span></span><a class="headerlink" href="#sys.abi_info.debug" title="Link to this definition">¶</a></dt>250<dd><p>A Boolean indicating whether the interpreter was built in251<a class="reference internal" href="../using/configure.html#debug-build"><span class="std std-ref">debug mode</span></a>.252This reflects either the presence of the <a class="reference internal" href="../using/configure.html#cmdoption-with-pydebug"><code class="xref std std-option docutils literal notranslate"><span class="pre">--with-pydebug</span></code></a>253<code class="file docutils literal notranslate"><span class="pre">configure</span></code> option (on Unix)254or the <code class="docutils literal notranslate"><span class="pre">Debug</span></code> configuration (on Windows).</p>255</dd></dl>256 257<dl class="py attribute">258<dt class="sig sig-object py" id="sys.abi_info.byteorder">259<span class="sig-prename descclassname"><span class="pre">abi_info.</span></span><span class="sig-name descname"><span class="pre">byteorder</span></span><a class="headerlink" href="#sys.abi_info.byteorder" title="Link to this definition">¶</a></dt>260<dd><p>A string indicating the native byte order,261either <code class="docutils literal notranslate"><span class="pre">'big'</span></code> or <code class="docutils literal notranslate"><span class="pre">'little'</span></code>.262This is the same as the <a class="reference internal" href="#sys.byteorder" title="sys.byteorder"><code class="xref py py-data docutils literal notranslate"><span class="pre">byteorder</span></code></a> attribute.</p>263</dd></dl>264 265</dd></dl>266 267<dl class="py data">268<dt class="sig sig-object py" id="sys.abiflags">269<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">abiflags</span></span><a class="headerlink" href="#sys.abiflags" title="Link to this definition">¶</a></dt>270<dd><p>On POSIX systems where Python was built with the standard <code class="docutils literal notranslate"><span class="pre">configure</span></code>271script, this contains the ABI flags as specified by <span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-3149/"><strong>PEP 3149</strong></a>.</p>272<div class="versionadded">273<p><span class="versionmodified added">Added in version 3.2.</span></p>274</div>275<div class="versionchanged">276<p><span class="versionmodified changed">Changed in version 3.8: </span>Default flags became an empty string (<code class="docutils literal notranslate"><span class="pre">m</span></code> flag for pymalloc has been277removed).</p>278</div>279<div class="availability docutils container">280<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix.</p>281</div>282</dd></dl>283 284<dl class="py function">285<dt class="sig sig-object py" id="sys.addaudithook">286<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">addaudithook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hook</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#sys.addaudithook" title="Link to this definition">¶</a></dt>287<dd><p>Append the callable <em>hook</em> to the list of active auditing hooks for the288current (sub)interpreter.</p>289<p>When an auditing event is raised through the <a class="reference internal" href="#sys.audit" title="sys.audit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.audit()</span></code></a> function, each290hook will be called in the order it was added with the event name and the291tuple of arguments. Native hooks added by <a class="reference internal" href="../c-api/sys.html#c.PySys_AddAuditHook" title="PySys_AddAuditHook"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddAuditHook()</span></code></a> are292called first, followed by hooks added in the current (sub)interpreter. Hooks293can then log the event, raise an exception to abort the operation,294or terminate the process entirely.</p>295<p>Note that audit hooks are primarily for collecting information about internal296or otherwise unobservable actions, whether by Python or libraries written in297Python. They are not suitable for implementing a “sandbox”. In particular,298malicious code can trivially disable or bypass hooks added using this299function. At a minimum, any security-sensitive hooks must be added using the300C API <a class="reference internal" href="../c-api/sys.html#c.PySys_AddAuditHook" title="PySys_AddAuditHook"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddAuditHook()</span></code></a> before initialising the runtime, and any301modules allowing arbitrary memory modification (such as <a class="reference internal" href="ctypes.html#module-ctypes" title="ctypes: A foreign function library for Python."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ctypes</span></code></a>) should302be completely removed or closely monitored.</p>303<p class="audit-hook"><p>Calling <a class="reference internal" href="#sys.addaudithook" title="sys.addaudithook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.addaudithook()</span></code></a> will itself raise an auditing event304named <code class="docutils literal notranslate"><span class="pre">sys.addaudithook</span></code> with no arguments. If any305existing hooks raise an exception derived from <a class="reference internal" href="exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-class docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>, the306new hook will not be added and the exception suppressed. As a result,307callers cannot assume that their hook has been added unless they control308all existing hooks.</p>309</p>310<p>See the <a class="reference internal" href="audit_events.html#audit-events"><span class="std std-ref">audit events table</span></a> for all events raised by311CPython, and <span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0578/"><strong>PEP 578</strong></a> for the original design discussion.</p>312<div class="versionadded">313<p><span class="versionmodified added">Added in version 3.8.</span></p>314</div>315<div class="versionchanged">316<p><span class="versionmodified changed">Changed in version 3.8.1: </span>Exceptions derived from <a class="reference internal" href="exceptions.html#Exception" title="Exception"><code class="xref py py-class docutils literal notranslate"><span class="pre">Exception</span></code></a> but not <a class="reference internal" href="exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-class docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>317are no longer suppressed.</p>318</div>319<div class="impl-detail compound">320<p><strong>CPython implementation detail:</strong> When tracing is enabled (see <a class="reference internal" href="#sys.settrace" title="sys.settrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">settrace()</span></code></a>), Python hooks are only321traced if the callable has a <code class="docutils literal notranslate"><span class="pre">__cantrace__</span></code> member that is set to a322true value. Otherwise, trace functions will skip the hook.</p>323</div>324</dd></dl>325 326<dl class="py data">327<dt class="sig sig-object py" id="sys.argv">328<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">argv</span></span><a class="headerlink" href="#sys.argv" title="Link to this definition">¶</a></dt>329<dd><p>The list of command line arguments passed to a Python script. <code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> is the330script name (it is operating system dependent whether this is a full pathname or331not). If the command was executed using the <a class="reference internal" href="../using/cmdline.html#cmdoption-c"><code class="xref std std-option docutils literal notranslate"><span class="pre">-c</span></code></a> command line option to332the interpreter, <code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> is set to the string <code class="docutils literal notranslate"><span class="pre">'-c'</span></code>. If no script name333was passed to the Python interpreter, <code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> is the empty string.</p>334<p>To loop over the standard input, or the list of files given on the335command line, see the <a class="reference internal" href="fileinput.html#module-fileinput" title="fileinput: Loop over standard input or a list of files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">fileinput</span></code></a> module.</p>336<p>See also <a class="reference internal" href="#sys.orig_argv" title="sys.orig_argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.orig_argv</span></code></a>.</p>337<div class="admonition note">338<p class="admonition-title">Note</p>339<p>On Unix, command line arguments are passed by bytes from OS. Python decodes340them with filesystem encoding and “surrogateescape” error handler.341When you need original bytes, you can get it by342<code class="docutils literal notranslate"><span class="pre">[os.fsencode(arg)</span> <span class="pre">for</span> <span class="pre">arg</span> <span class="pre">in</span> <span class="pre">sys.argv]</span></code>.</p>343</div>344</dd></dl>345 346<dl class="py function" id="auditing">347<dt class="sig sig-object py" id="sys.audit">348<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">audit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">event</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#sys.audit" title="Link to this definition">¶</a></dt>349<dd><p id="index-2">Raise an auditing event and trigger any active auditing hooks.350<em>event</em> is a string identifying the event, and <em>args</em> may contain351optional arguments with more information about the event. The352number and types of arguments for a given event are considered a353public and stable API and should not be modified between releases.</p>354<p>For example, one auditing event is named <code class="docutils literal notranslate"><span class="pre">os.chdir</span></code>. This event has355one argument called <em>path</em> that will contain the requested new356working directory.</p>357<p><a class="reference internal" href="#sys.audit" title="sys.audit"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.audit()</span></code></a> will call the existing auditing hooks, passing358the event name and arguments, and will re-raise the first exception359from any hook. In general, if an exception is raised, it should not360be handled and the process should be terminated as quickly as361possible. This allows hook implementations to decide how to respond362to particular events: they can merely log the event or abort the363operation by raising an exception.</p>364<p>Hooks are added using the <a class="reference internal" href="#sys.addaudithook" title="sys.addaudithook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.addaudithook()</span></code></a> or365<a class="reference internal" href="../c-api/sys.html#c.PySys_AddAuditHook" title="PySys_AddAuditHook"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_AddAuditHook()</span></code></a> functions.</p>366<p>The native equivalent of this function is <a class="reference internal" href="../c-api/sys.html#c.PySys_Audit" title="PySys_Audit"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_Audit()</span></code></a>. Using the367native function is preferred when possible.</p>368<p>See the <a class="reference internal" href="audit_events.html#audit-events"><span class="std std-ref">audit events table</span></a> for all events raised by369CPython.</p>370<div class="versionadded">371<p><span class="versionmodified added">Added in version 3.8.</span></p>372</div>373</dd></dl>374 375<dl class="py data">376<dt class="sig sig-object py" id="sys.base_exec_prefix">377<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">base_exec_prefix</span></span><a class="headerlink" href="#sys.base_exec_prefix" title="Link to this definition">¶</a></dt>378<dd><p>Equivalent to <a class="reference internal" href="#sys.exec_prefix" title="sys.exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">exec_prefix</span></code></a>, but referring to the base Python installation.</p>379<p>When running under <a class="reference internal" href="sys_path_init.html#sys-path-init-virtual-environments"><span class="std std-ref">Virtual Environments</span></a>,380<a class="reference internal" href="#sys.exec_prefix" title="sys.exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">exec_prefix</span></code></a> gets overwritten to the virtual environment prefix.381<code class="xref py py-data docutils literal notranslate"><span class="pre">base_exec_prefix</span></code>, conversely, does not change, and always points to382the base Python installation.383Refer to <span class="xref std std-ref">sys-path-init-virtual-environments</span> for more information.</p>384<div class="versionadded">385<p><span class="versionmodified added">Added in version 3.3.</span></p>386</div>387</dd></dl>388 389<dl class="py data">390<dt class="sig sig-object py" id="sys.base_prefix">391<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">base_prefix</span></span><a class="headerlink" href="#sys.base_prefix" title="Link to this definition">¶</a></dt>392<dd><p>Equivalent to <a class="reference internal" href="#sys.prefix" title="sys.prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">prefix</span></code></a>, but referring to the base Python installation.</p>393<p>When running under <a class="reference internal" href="venv.html#venv-def"><span class="std std-ref">virtual environment</span></a>,394<a class="reference internal" href="#sys.prefix" title="sys.prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">prefix</span></code></a> gets overwritten to the virtual environment prefix.395<code class="xref py py-data docutils literal notranslate"><span class="pre">base_prefix</span></code>, conversely, does not change, and always points to396the base Python installation.397Refer to <a class="reference internal" href="sys_path_init.html#sys-path-init-virtual-environments"><span class="std std-ref">Virtual Environments</span></a> for more information.</p>398<div class="versionadded">399<p><span class="versionmodified added">Added in version 3.3.</span></p>400</div>401</dd></dl>402 403<dl class="py data">404<dt class="sig sig-object py" id="sys.byteorder">405<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">byteorder</span></span><a class="headerlink" href="#sys.byteorder" title="Link to this definition">¶</a></dt>406<dd><p>An indicator of the native byte order. This will have the value <code class="docutils literal notranslate"><span class="pre">'big'</span></code> on407big-endian (most-significant byte first) platforms, and <code class="docutils literal notranslate"><span class="pre">'little'</span></code> on408little-endian (least-significant byte first) platforms.</p>409</dd></dl>410 411<dl class="py data">412<dt class="sig sig-object py" id="sys.builtin_module_names">413<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">builtin_module_names</span></span><a class="headerlink" href="#sys.builtin_module_names" title="Link to this definition">¶</a></dt>414<dd><p>A tuple of strings containing the names of all modules that are compiled into this415Python interpreter. (This information is not available in any other way —416<code class="docutils literal notranslate"><span class="pre">modules.keys()</span></code> only lists the imported modules.)</p>417<p>See also the <a class="reference internal" href="#sys.stdlib_module_names" title="sys.stdlib_module_names"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdlib_module_names</span></code></a> list.</p>418</dd></dl>419 420<dl class="py function">421<dt class="sig sig-object py" id="sys.call_tracing">422<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">call_tracing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#sys.call_tracing" title="Link to this definition">¶</a></dt>423<dd><p>Call <code class="docutils literal notranslate"><span class="pre">func(*args)</span></code>, while tracing is enabled. The tracing state is saved,424and restored afterwards. This is intended to be called from a debugger from425a checkpoint, to recursively debug or profile some other code.</p>426<p>Tracing is suspended while calling a tracing function set by427<a class="reference internal" href="#sys.settrace" title="sys.settrace"><code class="xref py py-func docutils literal notranslate"><span class="pre">settrace()</span></code></a> or <a class="reference internal" href="#sys.setprofile" title="sys.setprofile"><code class="xref py py-func docutils literal notranslate"><span class="pre">setprofile()</span></code></a> to avoid infinite recursion.428<code class="xref py py-func docutils literal notranslate"><span class="pre">call_tracing()</span></code> enables explicit recursion of the tracing function.</p>429</dd></dl>430 431<dl class="py data">432<dt class="sig sig-object py" id="sys.copyright">433<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">copyright</span></span><a class="headerlink" href="#sys.copyright" title="Link to this definition">¶</a></dt>434<dd><p>A string containing the copyright pertaining to the Python interpreter.</p>435</dd></dl>436 437<dl class="py function">438<dt class="sig sig-object py" id="sys._clear_type_cache">439<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">_clear_type_cache</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._clear_type_cache" title="Link to this definition">¶</a></dt>440<dd><p>Clear the internal type cache. The type cache is used to speed up attribute441and method lookups. Use the function <em>only</em> to drop unnecessary references442during reference leak debugging.</p>443<p>This function should be used for internal and specialized purposes only.</p>444<div class="deprecated">445<p><span class="versionmodified deprecated">Deprecated since version 3.13: </span>Use the more general <a class="reference internal" href="#sys._clear_internal_caches" title="sys._clear_internal_caches"><code class="xref py py-func docutils literal notranslate"><span class="pre">_clear_internal_caches()</span></code></a> function instead.</p>446</div>447</dd></dl>448 449<dl class="py function">450<dt class="sig sig-object py" id="sys._clear_internal_caches">451<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">_clear_internal_caches</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._clear_internal_caches" title="Link to this definition">¶</a></dt>452<dd><p>Clear all internal performance-related caches. Use this function <em>only</em> to453release unnecessary references and memory blocks when hunting for leaks.</p>454<div class="versionadded">455<p><span class="versionmodified added">Added in version 3.13.</span></p>456</div>457</dd></dl>458 459<dl class="py function">460<dt class="sig sig-object py" id="sys._current_frames">461<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">_current_frames</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._current_frames" title="Link to this definition">¶</a></dt>462<dd><p>Return a dictionary mapping each thread’s identifier to the topmost stack frame463currently active in that thread at the time the function is called. Note that464functions in the <a class="reference internal" href="traceback.html#module-traceback" title="traceback: Print or retrieve a stack traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">traceback</span></code></a> module can build the call stack given such a465frame.</p>466<p>This is most useful for debugging deadlock: this function does not require the467deadlocked threads’ cooperation, and such threads’ call stacks are frozen for as468long as they remain deadlocked. The frame returned for a non-deadlocked thread469may bear no relationship to that thread’s current activity by the time calling470code examines the frame.</p>471<p>This function should be used for internal and specialized purposes only.</p>472<p class="audit-hook">Raises an <a class="reference internal" href="#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">sys._current_frames</span></code> with no arguments.</p>473</dd></dl>474 475<dl class="py function">476<dt class="sig sig-object py" id="sys._current_exceptions">477<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">_current_exceptions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._current_exceptions" title="Link to this definition">¶</a></dt>478<dd><p>Return a dictionary mapping each thread’s identifier to the topmost exception479currently active in that thread at the time the function is called.480If a thread is not currently handling an exception, it is not included in481the result dictionary.</p>482<p>This is most useful for statistical profiling.</p>483<p>This function should be used for internal and specialized purposes only.</p>484<p class="audit-hook">Raises an <a class="reference internal" href="#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">sys._current_exceptions</span></code> with no arguments.</p>485<div class="versionchanged">486<p><span class="versionmodified changed">Changed in version 3.12: </span>Each value in the dictionary is now a single exception instance, rather487than a 3-tuple as returned from <code class="docutils literal notranslate"><span class="pre">sys.exc_info()</span></code>.</p>488</div>489</dd></dl>490 491<dl class="py function">492<dt class="sig sig-object py" id="sys.breakpointhook">493<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">breakpointhook</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.breakpointhook" title="Link to this definition">¶</a></dt>494<dd><p>This hook function is called by built-in <a class="reference internal" href="functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a>. By default,495it drops you into the <a class="reference internal" href="pdb.html#module-pdb" title="pdb: The Python debugger for interactive interpreters."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pdb</span></code></a> debugger, but it can be set to any other496function so that you can choose which debugger gets used.</p>497<p>The signature of this function is dependent on what it calls. For example,498the default binding (e.g. <code class="docutils literal notranslate"><span class="pre">pdb.set_trace()</span></code>) expects no arguments, but499you might bind it to a function that expects additional arguments500(positional and/or keyword). The built-in <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code> function passes501its <code class="docutils literal notranslate"><span class="pre">*args</span></code> and <code class="docutils literal notranslate"><span class="pre">**kws</span></code> straight through. Whatever502<code class="docutils literal notranslate"><span class="pre">breakpointhooks()</span></code> returns is returned from <code class="docutils literal notranslate"><span class="pre">breakpoint()</span></code>.</p>503<p>The default implementation first consults the environment variable504<span class="target" id="index-3"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONBREAKPOINT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT</span></code></a>. If that is set to <code class="docutils literal notranslate"><span class="pre">"0"</span></code> then this function505returns immediately; i.e. it is a no-op. If the environment variable is506not set, or is set to the empty string, <code class="docutils literal notranslate"><span class="pre">pdb.set_trace()</span></code> is called.507Otherwise this variable should name a function to run, using Python’s508dotted-import nomenclature, e.g. <code class="docutils literal notranslate"><span class="pre">package.subpackage.module.function</span></code>.509In this case, <code class="docutils literal notranslate"><span class="pre">package.subpackage.module</span></code> would be imported and the510resulting module must have a callable named <code class="docutils literal notranslate"><span class="pre">function()</span></code>. This is run,511passing in <code class="docutils literal notranslate"><span class="pre">*args</span></code> and <code class="docutils literal notranslate"><span class="pre">**kws</span></code>, and whatever <code class="docutils literal notranslate"><span class="pre">function()</span></code> returns,512<code class="docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code> returns to the built-in <a class="reference internal" href="functions.html#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a>513function.</p>514<p>Note that if anything goes wrong while importing the callable named by515<span class="target" id="index-4"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONBREAKPOINT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT</span></code></a>, a <a class="reference internal" href="exceptions.html#RuntimeWarning" title="RuntimeWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeWarning</span></code></a> is reported and the516breakpoint is ignored.</p>517<p>Also note that if <code class="docutils literal notranslate"><span class="pre">sys.breakpointhook()</span></code> is overridden programmatically,518<span class="target" id="index-5"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONBREAKPOINT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONBREAKPOINT</span></code></a> is <em>not</em> consulted.</p>519<div class="versionadded">520<p><span class="versionmodified added">Added in version 3.7.</span></p>521</div>522</dd></dl>523 524<dl class="py function">525<dt class="sig sig-object py" id="sys._debugmallocstats">526<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">_debugmallocstats</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys._debugmallocstats" title="Link to this definition">¶</a></dt>527<dd><p>Print low-level information to stderr about the state of CPython’s memory528allocator.</p>529<p>If Python is <a class="reference internal" href="../using/configure.html#debug-build"><span class="std std-ref">built in debug mode</span></a> (<a class="reference internal" href="../using/configure.html#cmdoption-with-pydebug"><code class="xref std std-option docutils literal notranslate"><span class="pre">configure</span>530<span class="pre">--with-pydebug</span> <span class="pre">option</span></code></a>), it also performs some expensive531internal consistency checks.</p>532<div class="versionadded">533<p><span class="versionmodified added">Added in version 3.3.</span></p>534</div>535<div class="impl-detail compound">536<p><strong>CPython implementation detail:</strong> This function is specific to CPython. The exact output format is not537defined here, and may change.</p>538</div>539</dd></dl>540 541<dl class="py data">542<dt class="sig sig-object py" id="sys.dllhandle">543<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">dllhandle</span></span><a class="headerlink" href="#sys.dllhandle" title="Link to this definition">¶</a></dt>544<dd><p>Integer specifying the handle of the Python DLL.</p>545<div class="availability docutils container">546<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: Windows.</p>547</div>548</dd></dl>549 550<dl class="py function">551<dt class="sig sig-object py" id="sys.displayhook">552<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">displayhook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#sys.displayhook" title="Link to this definition">¶</a></dt>553<dd><p>If <em>value</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, this function prints <code class="docutils literal notranslate"><span class="pre">repr(value)</span></code> to554<code class="docutils literal notranslate"><span class="pre">sys.stdout</span></code>, and saves <em>value</em> in <code class="docutils literal notranslate"><span class="pre">builtins._</span></code>. If <code class="docutils literal notranslate"><span class="pre">repr(value)</span></code> is555not encodable to <code class="docutils literal notranslate"><span class="pre">sys.stdout.encoding</span></code> with <code class="docutils literal notranslate"><span class="pre">sys.stdout.errors</span></code> error556handler (which is probably <code class="docutils literal notranslate"><span class="pre">'strict'</span></code>), encode it to557<code class="docutils literal notranslate"><span class="pre">sys.stdout.encoding</span></code> with <code class="docutils literal notranslate"><span class="pre">'backslashreplace'</span></code> error handler.</p>558<p><code class="docutils literal notranslate"><span class="pre">sys.displayhook</span></code> is called on the result of evaluating an <a class="reference internal" href="../glossary.html#term-expression"><span class="xref std std-term">expression</span></a>559entered in an interactive Python session. The display of these values can be560customized by assigning another one-argument function to <code class="docutils literal notranslate"><span class="pre">sys.displayhook</span></code>.</p>561<p>Pseudo-code:</p>562<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">displayhook</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>563 <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>564 <span class="k">return</span>565 <span class="c1"># Set '_' to None to avoid recursion</span>566 <span class="n">builtins</span><span class="o">.</span><span class="n">_</span> <span class="o">=</span> <span class="kc">None</span>567 <span class="n">text</span> <span class="o">=</span> <span class="nb">repr</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>568 <span class="k">try</span><span class="p">:</span>569 <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>570 <span class="k">except</span> <span class="ne">UnicodeEncodeError</span><span class="p">:</span>571 <span class="nb">bytes</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">encoding</span><span class="p">,</span> <span class="s1">'backslashreplace'</span><span class="p">)</span>572 <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="s1">'buffer'</span><span class="p">):</span>573 <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">buffer</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="nb">bytes</span><span class="p">)</span>574 <span class="k">else</span><span class="p">:</span>575 <span class="n">text</span> <span class="o">=</span> <span class="nb">bytes</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">encoding</span><span class="p">,</span> <span class="s1">'strict'</span><span class="p">)</span>576 <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>577 <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>578 <span class="n">builtins</span><span class="o">.</span><span class="n">_</span> <span class="o">=</span> <span class="n">value</span>579</pre></div>580</div>581<div class="versionchanged">582<p><span class="versionmodified changed">Changed in version 3.2: </span>Use <code class="docutils literal notranslate"><span class="pre">'backslashreplace'</span></code> error handler on <a class="reference internal" href="exceptions.html#UnicodeEncodeError" title="UnicodeEncodeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">UnicodeEncodeError</span></code></a>.</p>583</div>584</dd></dl>585 586<dl class="py data">587<dt class="sig sig-object py" id="sys.dont_write_bytecode">588<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">dont_write_bytecode</span></span><a class="headerlink" href="#sys.dont_write_bytecode" title="Link to this definition">¶</a></dt>589<dd><p>If this is true, Python won’t try to write <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files on the590import of source modules. This value is initially set to <code class="docutils literal notranslate"><span class="pre">True</span></code> or591<code class="docutils literal notranslate"><span class="pre">False</span></code> depending on the <a class="reference internal" href="../using/cmdline.html#cmdoption-B"><code class="xref std std-option docutils literal notranslate"><span class="pre">-B</span></code></a> command line option and the592<span class="target" id="index-6"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONDONTWRITEBYTECODE</span></code></a> environment variable, but you can set it593yourself to control bytecode file generation.</p>594</dd></dl>595 596<dl class="py data">597<dt class="sig sig-object py" id="sys._emscripten_info">598<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">_emscripten_info</span></span><a class="headerlink" href="#sys._emscripten_info" title="Link to this definition">¶</a></dt>599<dd><p>A <a class="reference internal" href="../glossary.html#term-named-tuple"><span class="xref std std-term">named tuple</span></a> holding information about the environment on the600<em>wasm32-emscripten</em> platform. The named tuple is provisional and may change601in the future.</p>602<dl class="py attribute">603<dt class="sig sig-object py" id="sys._emscripten_info.emscripten_version">604<span class="sig-prename descclassname"><span class="pre">_emscripten_info.</span></span><span class="sig-name descname"><span class="pre">emscripten_version</span></span><a class="headerlink" href="#sys._emscripten_info.emscripten_version" title="Link to this definition">¶</a></dt>605<dd><p>Emscripten version as tuple of ints (major, minor, micro), e.g. <code class="docutils literal notranslate"><span class="pre">(3,</span> <span class="pre">1,</span> <span class="pre">8)</span></code>.</p>606</dd></dl>607 608<dl class="py attribute">609<dt class="sig sig-object py" id="sys._emscripten_info.runtime">610<span class="sig-prename descclassname"><span class="pre">_emscripten_info.</span></span><span class="sig-name descname"><span class="pre">runtime</span></span><a class="headerlink" href="#sys._emscripten_info.runtime" title="Link to this definition">¶</a></dt>611<dd><p>Runtime string, e.g. browser user agent, <code class="docutils literal notranslate"><span class="pre">'Node.js</span> <span class="pre">v14.18.2'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'UNKNOWN'</span></code>.</p>612</dd></dl>613 614<dl class="py attribute">615<dt class="sig sig-object py" id="sys._emscripten_info.pthreads">616<span class="sig-prename descclassname"><span class="pre">_emscripten_info.</span></span><span class="sig-name descname"><span class="pre">pthreads</span></span><a class="headerlink" href="#sys._emscripten_info.pthreads" title="Link to this definition">¶</a></dt>617<dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if Python is compiled with Emscripten pthreads support.</p>618</dd></dl>619 620<dl class="py attribute">621<dt class="sig sig-object py" id="sys._emscripten_info.shared_memory">622<span class="sig-prename descclassname"><span class="pre">_emscripten_info.</span></span><span class="sig-name descname"><span class="pre">shared_memory</span></span><a class="headerlink" href="#sys._emscripten_info.shared_memory" title="Link to this definition">¶</a></dt>623<dd><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if Python is compiled with shared memory support.</p>624</dd></dl>625 626<div class="availability docutils container">627<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: Emscripten.</p>628</div>629<div class="versionadded">630<p><span class="versionmodified added">Added in version 3.11.</span></p>631</div>632</dd></dl>633 634<dl class="py data">635<dt class="sig sig-object py" id="sys.pycache_prefix">636<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">pycache_prefix</span></span><a class="headerlink" href="#sys.pycache_prefix" title="Link to this definition">¶</a></dt>637<dd><p>If this is set (not <code class="docutils literal notranslate"><span class="pre">None</span></code>), Python will write bytecode-cache <code class="docutils literal notranslate"><span class="pre">.pyc</span></code>638files to (and read them from) a parallel directory tree rooted at this639directory, rather than from <code class="docutils literal notranslate"><span class="pre">__pycache__</span></code> directories in the source code640tree. Any <code class="docutils literal notranslate"><span class="pre">__pycache__</span></code> directories in the source code tree will be ignored641and new <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files written within the pycache prefix. Thus if you use642<a class="reference internal" href="compileall.html#module-compileall" title="compileall: Tools for byte-compiling all Python source files in a directory tree."><code class="xref py py-mod docutils literal notranslate"><span class="pre">compileall</span></code></a> as a pre-build step, you must ensure you run it with the643same pycache prefix (if any) that you will use at runtime.</p>644<p>A relative path is interpreted relative to the current working directory.</p>645<p>This value is initially set based on the value of the <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a>646<code class="docutils literal notranslate"><span class="pre">pycache_prefix=PATH</span></code> command-line option or the647<span class="target" id="index-7"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONPYCACHEPREFIX"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPYCACHEPREFIX</span></code></a> environment variable (command-line takes648precedence). If neither are set, it is <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>649<div class="versionadded">650<p><span class="versionmodified added">Added in version 3.8.</span></p>651</div>652</dd></dl>653 654<dl class="py function">655<dt class="sig sig-object py" id="sys.excepthook">656<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">excepthook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">traceback</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#sys.excepthook" title="Link to this definition">¶</a></dt>657<dd><p>This function prints out a given traceback and exception to <code class="docutils literal notranslate"><span class="pre">sys.stderr</span></code>.</p>658<p>When an exception other than <a class="reference internal" href="exceptions.html#SystemExit" title="SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> is raised and uncaught, the interpreter calls659<code class="docutils literal notranslate"><span class="pre">sys.excepthook</span></code> with three arguments, the exception class, exception660instance, and a traceback object. In an interactive session this happens just661before control is returned to the prompt; in a Python program this happens just662before the program exits. The handling of such top-level exceptions can be663customized by assigning another three-argument function to <code class="docutils literal notranslate"><span class="pre">sys.excepthook</span></code>.</p>664<p class="audit-hook"><p>Raise an auditing event <code class="docutils literal notranslate"><span class="pre">sys.excepthook</span></code> with arguments <code class="docutils literal notranslate"><span class="pre">hook</span></code>,665<code class="docutils literal notranslate"><span class="pre">type</span></code>, <code class="docutils literal notranslate"><span class="pre">value</span></code>, <code class="docutils literal notranslate"><span class="pre">traceback</span></code> when an uncaught exception occurs.666If no hook has been set, <code class="docutils literal notranslate"><span class="pre">hook</span></code> may be <code class="docutils literal notranslate"><span class="pre">None</span></code>. If any hook raises667an exception derived from <a class="reference internal" href="exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-class docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> the call to the hook will668be suppressed. Otherwise, the audit hook exception will be reported as669unraisable and <code class="docutils literal notranslate"><span class="pre">sys.excepthook</span></code> will be called.</p>670</p>671<div class="admonition seealso">672<p class="admonition-title">See also</p>673<p>The <a class="reference internal" href="#sys.unraisablehook" title="sys.unraisablehook"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.unraisablehook()</span></code></a> function handles unraisable exceptions674and the <a class="reference internal" href="threading.html#threading.excepthook" title="threading.excepthook"><code class="xref py py-func docutils literal notranslate"><span class="pre">threading.excepthook()</span></code></a> function handles exception raised675by <a class="reference internal" href="threading.html#threading.Thread.run" title="threading.Thread.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">threading.Thread.run()</span></code></a>.</p>676</div>677</dd></dl>678 679<dl class="py data">680<dt class="sig sig-object py" id="sys.__breakpointhook__">681<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">__breakpointhook__</span></span><a class="headerlink" href="#sys.__breakpointhook__" title="Link to this definition">¶</a></dt>682<dt class="sig sig-object py" id="sys.__displayhook__">683<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">__displayhook__</span></span><a class="headerlink" href="#sys.__displayhook__" title="Link to this definition">¶</a></dt>684<dt class="sig sig-object py" id="sys.__excepthook__">685<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">__excepthook__</span></span><a class="headerlink" href="#sys.__excepthook__" title="Link to this definition">¶</a></dt>686<dt class="sig sig-object py" id="sys.__unraisablehook__">687<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">__unraisablehook__</span></span><a class="headerlink" href="#sys.__unraisablehook__" title="Link to this definition">¶</a></dt>688<dd><p>These objects contain the original values of <code class="docutils literal notranslate"><span class="pre">breakpointhook</span></code>,689<code class="docutils literal notranslate"><span class="pre">displayhook</span></code>, <code class="docutils literal notranslate"><span class="pre">excepthook</span></code>, and <code class="docutils literal notranslate"><span class="pre">unraisablehook</span></code> at the start of the690program. They are saved so that <code class="docutils literal notranslate"><span class="pre">breakpointhook</span></code>, <code class="docutils literal notranslate"><span class="pre">displayhook</span></code> and691<code class="docutils literal notranslate"><span class="pre">excepthook</span></code>, <code class="docutils literal notranslate"><span class="pre">unraisablehook</span></code> can be restored in case they happen to692get replaced with broken or alternative objects.</p>693<div class="versionadded">694<p><span class="versionmodified added">Added in version 3.7: </span>__breakpointhook__</p>695</div>696<div class="versionadded">697<p><span class="versionmodified added">Added in version 3.8: </span>__unraisablehook__</p>698</div>699</dd></dl>700 701<dl class="py function">702<dt class="sig sig-object py" id="sys.exception">703<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">exception</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.exception" title="Link to this definition">¶</a></dt>704<dd><p>This function, when called while an exception handler is executing (such as705an <code class="docutils literal notranslate"><span class="pre">except</span></code> or <code class="docutils literal notranslate"><span class="pre">except*</span></code> clause), returns the exception instance that706was caught by this handler. When exception handlers are nested within one707another, only the exception handled by the innermost handler is accessible.</p>708<p>If no exception handler is executing, this function returns <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>709<div class="versionadded">710<p><span class="versionmodified added">Added in version 3.11.</span></p>711</div>712</dd></dl>713 714<dl class="py function">715<dt class="sig sig-object py" id="sys.exc_info">716<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">exc_info</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.exc_info" title="Link to this definition">¶</a></dt>717<dd><p>This function returns the old-style representation of the handled718exception. If an exception <code class="docutils literal notranslate"><span class="pre">e</span></code> is currently handled (so719<a class="reference internal" href="#sys.exception" title="sys.exception"><code class="xref py py-func docutils literal notranslate"><span class="pre">exception()</span></code></a> would return <code class="docutils literal notranslate"><span class="pre">e</span></code>), <code class="xref py py-func docutils literal notranslate"><span class="pre">exc_info()</span></code> returns the720tuple <code class="docutils literal notranslate"><span class="pre">(type(e),</span> <span class="pre">e,</span> <span class="pre">e.__traceback__)</span></code>.721That is, a tuple containing the type of the exception (a subclass of722<a class="reference internal" href="exceptions.html#BaseException" title="BaseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BaseException</span></code></a>), the exception itself, and a <a class="reference internal" href="../reference/datamodel.html#traceback-objects"><span class="std std-ref">traceback723object</span></a> which typically encapsulates the call724stack at the point where the exception last occurred.</p>725<p id="index-8">If no exception is being handled anywhere on the stack, this function726return a tuple containing three <code class="docutils literal notranslate"><span class="pre">None</span></code> values.</p>727<div class="versionchanged">728<p><span class="versionmodified changed">Changed in version 3.11: </span>The <code class="docutils literal notranslate"><span class="pre">type</span></code> and <code class="docutils literal notranslate"><span class="pre">traceback</span></code> fields are now derived from the <code class="docutils literal notranslate"><span class="pre">value</span></code>729(the exception instance), so when an exception is modified while it is730being handled, the changes are reflected in the results of subsequent731calls to <code class="xref py py-func docutils literal notranslate"><span class="pre">exc_info()</span></code>.</p>732</div>733</dd></dl>734 735<dl class="py data">736<dt class="sig sig-object py" id="sys.exec_prefix">737<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">exec_prefix</span></span><a class="headerlink" href="#sys.exec_prefix" title="Link to this definition">¶</a></dt>738<dd><p>A string giving the site-specific directory prefix where the platform-dependent739Python files are installed; by default, this is also <code class="docutils literal notranslate"><span class="pre">'/usr/local'</span></code>. This can740be set at build time with the <code class="docutils literal notranslate"><span class="pre">--exec-prefix</span></code> argument to the741<strong class="program">configure</strong> script. Specifically, all configuration files (e.g. the742<code class="file docutils literal notranslate"><span class="pre">pyconfig.h</span></code> header file) are installed in the directory743<code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">X.Y</span></em><span class="pre">/config</span></code>, and shared library modules are744installed in <code class="file docutils literal notranslate"><em><span class="pre">exec_prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">X.Y</span></em><span class="pre">/lib-dynload</span></code>, where <em>X.Y</em>745is the version number of Python, for example <code class="docutils literal notranslate"><span class="pre">3.2</span></code>.</p>746<div class="admonition note">747<p class="admonition-title">Note</p>748<p>If a <a class="reference internal" href="venv.html#venv-def"><span class="std std-ref">virtual environment</span></a> is in effect, this <code class="xref py py-data docutils literal notranslate"><span class="pre">exec_prefix</span></code>749will point to the virtual environment. The value for the Python installation750will still be available, via <a class="reference internal" href="#sys.base_exec_prefix" title="sys.base_exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">base_exec_prefix</span></code></a>.751Refer to <a class="reference internal" href="sys_path_init.html#sys-path-init-virtual-environments"><span class="std std-ref">Virtual Environments</span></a> for more information.</p>752</div>753<div class="versionchanged">754<p><span class="versionmodified changed">Changed in version 3.14: </span>When running under a <a class="reference internal" href="venv.html#venv-def"><span class="std std-ref">virtual environment</span></a>,755<a class="reference internal" href="#sys.prefix" title="sys.prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">prefix</span></code></a> and <code class="xref py py-data docutils literal notranslate"><span class="pre">exec_prefix</span></code> are now set to the virtual756environment prefix by the <a class="reference internal" href="sys_path_init.html#sys-path-init"><span class="std std-ref">path initialization</span></a>,757instead of <a class="reference internal" href="site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a>. This means that <code class="xref py py-data docutils literal notranslate"><span class="pre">prefix</span></code> and758<code class="xref py py-data docutils literal notranslate"><span class="pre">exec_prefix</span></code> always point to the virtual environment, even when759<code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code> is disabled (<a class="reference internal" href="../using/cmdline.html#cmdoption-S"><code class="xref std std-option docutils literal notranslate"><span class="pre">-S</span></code></a>).</p>760</div>761</dd></dl>762 763<dl class="py data">764<dt class="sig sig-object py" id="sys.executable">765<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">executable</span></span><a class="headerlink" href="#sys.executable" title="Link to this definition">¶</a></dt>766<dd><p>A string giving the absolute path of the executable binary for the Python767interpreter, on systems where this makes sense. If Python is unable to retrieve768the real path to its executable, <a class="reference internal" href="#sys.executable" title="sys.executable"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.executable</span></code></a> will be an empty string769or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>770</dd></dl>771 772<dl class="py function">773<dt class="sig sig-object py" id="sys.exit">774<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">exit</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">arg</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.exit" title="Link to this definition">¶</a></dt>775<dd><p>Raise a <a class="reference internal" href="exceptions.html#SystemExit" title="SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> exception, signaling an intention to exit the interpreter.</p>776<p>The optional argument <em>arg</em> can be an integer giving the exit status777(defaulting to zero), or another type of object. If it is an integer, zero778is considered “successful termination” and any nonzero value is considered779“abnormal termination” by shells and the like. Most systems require it to be780in the range 0–127, and produce undefined results otherwise. Some systems781have a convention for assigning specific meanings to specific exit codes, but782these are generally underdeveloped; Unix programs generally use 2 for command783line syntax errors and 1 for all other kinds of errors. If another type of784object is passed, <code class="docutils literal notranslate"><span class="pre">None</span></code> is equivalent to passing zero, and any other785object is printed to <a class="reference internal" href="#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">stderr</span></code></a> and results in an exit code of 1. In786particular, <code class="docutils literal notranslate"><span class="pre">sys.exit("some</span> <span class="pre">error</span> <span class="pre">message")</span></code> is a quick way to exit a787program when an error occurs.</p>788<p>Since <code class="xref py py-func docutils literal notranslate"><span class="pre">exit()</span></code> ultimately “only” raises an exception, it will only exit789the process when called from the main thread, and the exception is not790intercepted. Cleanup actions specified by <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> clauses of791<a class="reference internal" href="../reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> statements are honored, and it is possible to intercept the792exit attempt at an outer level.</p>793<div class="versionchanged">794<p><span class="versionmodified changed">Changed in version 3.6: </span>If an error occurs in the cleanup after the Python interpreter795has caught <a class="reference internal" href="exceptions.html#SystemExit" title="SystemExit"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemExit</span></code></a> (such as an error flushing buffered data796in the standard streams), the exit status is changed to 120.</p>797</div>798</dd></dl>799 800<dl class="py data">801<dt class="sig sig-object py" id="sys.flags">802<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">flags</span></span><a class="headerlink" href="#sys.flags" title="Link to this definition">¶</a></dt>803<dd><p>The <a class="reference internal" href="../glossary.html#term-named-tuple"><span class="xref std std-term">named tuple</span></a> <em>flags</em> exposes the status of command line804flags. Flags should only be accessed only by name and not by index. The805attributes are read only.</p>806<table class="docutils align-default">807<tbody>808<tr class="row-odd"><td><dl class="py attribute">809<dt class="sig sig-object py" id="sys.flags.debug">810<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">debug</span></span><a class="headerlink" href="#sys.flags.debug" title="Link to this definition">¶</a></dt>811<dd></dd></dl>812 813</td>814<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-d"><code class="xref std std-option docutils literal notranslate"><span class="pre">-d</span></code></a></p></td>815</tr>816<tr class="row-even"><td><dl class="py attribute">817<dt class="sig sig-object py" id="sys.flags.inspect">818<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">inspect</span></span><a class="headerlink" href="#sys.flags.inspect" title="Link to this definition">¶</a></dt>819<dd></dd></dl>820 821</td>822<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a></p></td>823</tr>824<tr class="row-odd"><td><dl class="py attribute">825<dt class="sig sig-object py" id="sys.flags.interactive">826<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">interactive</span></span><a class="headerlink" href="#sys.flags.interactive" title="Link to this definition">¶</a></dt>827<dd></dd></dl>828 829</td>830<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a></p></td>831</tr>832<tr class="row-even"><td><dl class="py attribute">833<dt class="sig sig-object py" id="sys.flags.isolated">834<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">isolated</span></span><a class="headerlink" href="#sys.flags.isolated" title="Link to this definition">¶</a></dt>835<dd></dd></dl>836 837</td>838<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-I"><code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code></a></p></td>839</tr>840<tr class="row-odd"><td><dl class="py attribute">841<dt class="sig sig-object py" id="sys.flags.optimize">842<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">optimize</span></span><a class="headerlink" href="#sys.flags.optimize" title="Link to this definition">¶</a></dt>843<dd></dd></dl>844 845</td>846<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-O"><code class="xref std std-option docutils literal notranslate"><span class="pre">-O</span></code></a> or <a class="reference internal" href="../using/cmdline.html#cmdoption-OO"><code class="xref std std-option docutils literal notranslate"><span class="pre">-OO</span></code></a></p></td>847</tr>848<tr class="row-even"><td><dl class="py attribute">849<dt class="sig sig-object py" id="sys.flags.dont_write_bytecode">850<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">dont_write_bytecode</span></span><a class="headerlink" href="#sys.flags.dont_write_bytecode" title="Link to this definition">¶</a></dt>851<dd></dd></dl>852 853</td>854<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-B"><code class="xref std std-option docutils literal notranslate"><span class="pre">-B</span></code></a></p></td>855</tr>856<tr class="row-odd"><td><dl class="py attribute">857<dt class="sig sig-object py" id="sys.flags.no_user_site">858<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">no_user_site</span></span><a class="headerlink" href="#sys.flags.no_user_site" title="Link to this definition">¶</a></dt>859<dd></dd></dl>860 861</td>862<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-s"><code class="xref std std-option docutils literal notranslate"><span class="pre">-s</span></code></a></p></td>863</tr>864<tr class="row-even"><td><dl class="py attribute">865<dt class="sig sig-object py" id="sys.flags.no_site">866<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">no_site</span></span><a class="headerlink" href="#sys.flags.no_site" title="Link to this definition">¶</a></dt>867<dd></dd></dl>868 869</td>870<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-S"><code class="xref std std-option docutils literal notranslate"><span class="pre">-S</span></code></a></p></td>871</tr>872<tr class="row-odd"><td><dl class="py attribute">873<dt class="sig sig-object py" id="sys.flags.ignore_environment">874<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">ignore_environment</span></span><a class="headerlink" href="#sys.flags.ignore_environment" title="Link to this definition">¶</a></dt>875<dd></dd></dl>876 877</td>878<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-E"><code class="xref std std-option docutils literal notranslate"><span class="pre">-E</span></code></a></p></td>879</tr>880<tr class="row-even"><td><dl class="py attribute">881<dt class="sig sig-object py" id="sys.flags.verbose">882<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">verbose</span></span><a class="headerlink" href="#sys.flags.verbose" title="Link to this definition">¶</a></dt>883<dd></dd></dl>884 885</td>886<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-v"><code class="xref std std-option docutils literal notranslate"><span class="pre">-v</span></code></a></p></td>887</tr>888<tr class="row-odd"><td><dl class="py attribute">889<dt class="sig sig-object py" id="sys.flags.bytes_warning">890<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">bytes_warning</span></span><a class="headerlink" href="#sys.flags.bytes_warning" title="Link to this definition">¶</a></dt>891<dd></dd></dl>892 893</td>894<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-b"><code class="xref std std-option docutils literal notranslate"><span class="pre">-b</span></code></a></p></td>895</tr>896<tr class="row-even"><td><dl class="py attribute">897<dt class="sig sig-object py" id="sys.flags.quiet">898<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">quiet</span></span><a class="headerlink" href="#sys.flags.quiet" title="Link to this definition">¶</a></dt>899<dd></dd></dl>900 901</td>902<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-q"><code class="xref std std-option docutils literal notranslate"><span class="pre">-q</span></code></a></p></td>903</tr>904<tr class="row-odd"><td><dl class="py attribute">905<dt class="sig sig-object py" id="sys.flags.hash_randomization">906<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">hash_randomization</span></span><a class="headerlink" href="#sys.flags.hash_randomization" title="Link to this definition">¶</a></dt>907<dd></dd></dl>908 909</td>910<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-R"><code class="xref std std-option docutils literal notranslate"><span class="pre">-R</span></code></a></p></td>911</tr>912<tr class="row-even"><td><dl class="py attribute">913<dt class="sig sig-object py" id="sys.flags.dev_mode">914<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">dev_mode</span></span><a class="headerlink" href="#sys.flags.dev_mode" title="Link to this definition">¶</a></dt>915<dd></dd></dl>916 917</td>918<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code></a> (<a class="reference internal" href="devmode.html#devmode"><span class="std std-ref">Python Development Mode</span></a>)</p></td>919</tr>920<tr class="row-odd"><td><dl class="py attribute">921<dt class="sig sig-object py" id="sys.flags.utf8_mode">922<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">utf8_mode</span></span><a class="headerlink" href="#sys.flags.utf8_mode" title="Link to this definition">¶</a></dt>923<dd></dd></dl>924 925</td>926<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8</span></code></a></p></td>927</tr>928<tr class="row-even"><td><dl class="py attribute">929<dt class="sig sig-object py" id="sys.flags.safe_path">930<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">safe_path</span></span><a class="headerlink" href="#sys.flags.safe_path" title="Link to this definition">¶</a></dt>931<dd></dd></dl>932 933</td>934<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-P"><code class="xref std std-option docutils literal notranslate"><span class="pre">-P</span></code></a></p></td>935</tr>936<tr class="row-odd"><td><dl class="py attribute">937<dt class="sig sig-object py" id="sys.flags.int_max_str_digits">938<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">int_max_str_digits</span></span><a class="headerlink" href="#sys.flags.int_max_str_digits" title="Link to this definition">¶</a></dt>939<dd></dd></dl>940 941</td>942<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">int_max_str_digits</span></code></a>943(<a class="reference internal" href="stdtypes.html#int-max-str-digits"><span class="std std-ref">integer string conversion length limitation</span></a>)</p></td>944</tr>945<tr class="row-even"><td><dl class="py attribute">946<dt class="sig sig-object py" id="sys.flags.warn_default_encoding">947<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">warn_default_encoding</span></span><a class="headerlink" href="#sys.flags.warn_default_encoding" title="Link to this definition">¶</a></dt>948<dd></dd></dl>949 950</td>951<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">warn_default_encoding</span></code></a></p></td>952</tr>953<tr class="row-odd"><td><dl class="py attribute">954<dt class="sig sig-object py" id="sys.flags.gil">955<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">gil</span></span><a class="headerlink" href="#sys.flags.gil" title="Link to this definition">¶</a></dt>956<dd></dd></dl>957 958</td>959<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">gil</span></code></a> and <span class="target" id="index-9"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHON_GIL"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_GIL</span></code></a></p></td>960</tr>961<tr class="row-even"><td><dl class="py attribute">962<dt class="sig sig-object py" id="sys.flags.thread_inherit_context">963<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">thread_inherit_context</span></span><a class="headerlink" href="#sys.flags.thread_inherit_context" title="Link to this definition">¶</a></dt>964<dd></dd></dl>965 966</td>967<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">thread_inherit_context</span></code></a> and968<span class="target" id="index-10"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHON_THREAD_INHERIT_CONTEXT"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_THREAD_INHERIT_CONTEXT</span></code></a></p></td>969</tr>970<tr class="row-odd"><td><dl class="py attribute">971<dt class="sig sig-object py" id="sys.flags.context_aware_warnings">972<span class="sig-prename descclassname"><span class="pre">flags.</span></span><span class="sig-name descname"><span class="pre">context_aware_warnings</span></span><a class="headerlink" href="#sys.flags.context_aware_warnings" title="Link to this definition">¶</a></dt>973<dd></dd></dl>974 975</td>976<td><p><a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">context_aware_warnings</span></code></a> and977<span class="target" id="index-11"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHON_CONTEXT_AWARE_WARNINGS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_CONTEXT_AWARE_WARNINGS</span></code></a></p></td>978</tr>979</tbody>980</table>981<div class="versionchanged">982<p><span class="versionmodified changed">Changed in version 3.2: </span>Added <code class="docutils literal notranslate"><span class="pre">quiet</span></code> attribute for the new <a class="reference internal" href="../using/cmdline.html#cmdoption-q"><code class="xref std std-option docutils literal notranslate"><span class="pre">-q</span></code></a> flag.</p>983</div>984<div class="versionadded">985<p><span class="versionmodified added">Added in version 3.2.3: </span>The <code class="docutils literal notranslate"><span class="pre">hash_randomization</span></code> attribute.</p>986</div>987<div class="versionchanged">988<p><span class="versionmodified changed">Changed in version 3.3: </span>Removed obsolete <code class="docutils literal notranslate"><span class="pre">division_warning</span></code> attribute.</p>989</div>990<div class="versionchanged">991<p><span class="versionmodified changed">Changed in version 3.4: </span>Added <code class="docutils literal notranslate"><span class="pre">isolated</span></code> attribute for <a class="reference internal" href="../using/cmdline.html#cmdoption-I"><code class="xref std std-option docutils literal notranslate"><span class="pre">-I</span></code></a> <code class="docutils literal notranslate"><span class="pre">isolated</span></code> flag.</p>992</div>993<div class="versionchanged">994<p><span class="versionmodified changed">Changed in version 3.7: </span>Added the <code class="docutils literal notranslate"><span class="pre">dev_mode</span></code> attribute for the new <a class="reference internal" href="devmode.html#devmode"><span class="std std-ref">Python Development995Mode</span></a> and the <code class="docutils literal notranslate"><span class="pre">utf8_mode</span></code> attribute for the new <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a>996<code class="docutils literal notranslate"><span class="pre">utf8</span></code> flag.</p>997</div>998<div class="versionchanged">999<p><span class="versionmodified changed">Changed in version 3.10: </span>Added <code class="docutils literal notranslate"><span class="pre">warn_default_encoding</span></code> attribute for <a class="reference internal" href="../using/cmdline.html#cmdoption-X"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a> <code class="docutils literal notranslate"><span class="pre">warn_default_encoding</span></code> flag.</p>1000</div>1001<div class="versionchanged">1002<p><span class="versionmodified changed">Changed in version 3.11: </span>Added the <code class="docutils literal notranslate"><span class="pre">safe_path</span></code> attribute for <a class="reference internal" href="../using/cmdline.html#cmdoption-P"><code class="xref std std-option docutils literal notranslate"><span class="pre">-P</span></code></a> option.</p>1003</div>1004<div class="versionchanged">1005<p><span class="versionmodified changed">Changed in version 3.11: </span>Added the <code class="docutils literal notranslate"><span class="pre">int_max_str_digits</span></code> attribute.</p>1006</div>1007<div class="versionchanged">1008<p><span class="versionmodified changed">Changed in version 3.13: </span>Added the <code class="docutils literal notranslate"><span class="pre">gil</span></code> attribute.</p>1009</div>1010<div class="versionchanged">1011<p><span class="versionmodified changed">Changed in version 3.14: </span>Added the <code class="docutils literal notranslate"><span class="pre">thread_inherit_context</span></code> attribute.</p>1012</div>1013<div class="versionchanged">1014<p><span class="versionmodified changed">Changed in version 3.14: </span>Added the <code class="docutils literal notranslate"><span class="pre">context_aware_warnings</span></code> attribute.</p>1015</div>1016</dd></dl>1017 1018<dl class="py data">1019<dt class="sig sig-object py" id="sys.float_info">1020<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">float_info</span></span><a class="headerlink" href="#sys.float_info" title="Link to this definition">¶</a></dt>1021<dd><p>A <a class="reference internal" href="../glossary.html#term-named-tuple"><span class="xref std std-term">named tuple</span></a> holding information about the float type. It1022contains low level information about the precision and internal1023representation. The values correspond to the various floating-point1024constants defined in the standard header file <code class="file docutils literal notranslate"><span class="pre">float.h</span></code> for the ‘C’1025programming language; see section 5.2.4.2.2 of the 1999 ISO/IEC C standard1026<a class="reference internal" href="#c99" id="id1"><span>[C99]</span></a>, ‘Characteristics of floating types’, for details.</p>1027<table class="docutils align-default" id="id2">1028<caption><span class="caption-text">Attributes of the <code class="xref py py-data docutils literal notranslate"><span class="pre">float_info</span></code> <a class="reference internal" href="../glossary.html#term-named-tuple"><span class="xref std std-term">named tuple</span></a></span><a class="headerlink" href="#id2" title="Link to this table">¶</a></caption>1029<thead>1030<tr class="row-odd"><th class="head"><p>attribute</p></th>1031<th class="head"><p>float.h macro</p></th>1032<th class="head"><p>explanation</p></th>1033</tr>1034</thead>1035<tbody>1036<tr class="row-even"><td><dl class="py attribute">1037<dt class="sig sig-object py" id="sys.float_info.epsilon">1038<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">epsilon</span></span><a class="headerlink" href="#sys.float_info.epsilon" title="Link to this definition">¶</a></dt>1039<dd></dd></dl>1040 1041</td>1042<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_EPSILON</span></code></p></td>1043<td><p>difference between 1.0 and the least value greater than 1.0 that is1044representable as a float.</p>1045<p>See also <a class="reference internal" href="math.html#math.ulp" title="math.ulp"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.ulp()</span></code></a>.</p>1046</td>1047</tr>1048<tr class="row-odd"><td><dl class="py attribute">1049<dt class="sig sig-object py" id="sys.float_info.dig">1050<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">dig</span></span><a class="headerlink" href="#sys.float_info.dig" title="Link to this definition">¶</a></dt>1051<dd></dd></dl>1052 1053</td>1054<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_DIG</span></code></p></td>1055<td><p>The maximum number of decimal digits that can be faithfully1056represented in a float; see below.</p></td>1057</tr>1058<tr class="row-even"><td><dl class="py attribute">1059<dt class="sig sig-object py" id="sys.float_info.mant_dig">1060<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">mant_dig</span></span><a class="headerlink" href="#sys.float_info.mant_dig" title="Link to this definition">¶</a></dt>1061<dd></dd></dl>1062 1063</td>1064<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MANT_DIG</span></code></p></td>1065<td><p>Float precision: the number of base-<code class="docutils literal notranslate"><span class="pre">radix</span></code> digits in the1066significand of a float.</p></td>1067</tr>1068<tr class="row-odd"><td><dl class="py attribute">1069<dt class="sig sig-object py" id="sys.float_info.max">1070<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">max</span></span><a class="headerlink" href="#sys.float_info.max" title="Link to this definition">¶</a></dt>1071<dd></dd></dl>1072 1073</td>1074<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MAX</span></code></p></td>1075<td><p>The maximum representable positive finite float.</p></td>1076</tr>1077<tr class="row-even"><td><dl class="py attribute">1078<dt class="sig sig-object py" id="sys.float_info.max_exp">1079<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">max_exp</span></span><a class="headerlink" href="#sys.float_info.max_exp" title="Link to this definition">¶</a></dt>1080<dd></dd></dl>1081 1082</td>1083<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MAX_EXP</span></code></p></td>1084<td><p>The maximum integer <em>e</em> such that <code class="docutils literal notranslate"><span class="pre">radix**(e-1)</span></code> is a representable1085finite float.</p></td>1086</tr>1087<tr class="row-odd"><td><dl class="py attribute">1088<dt class="sig sig-object py" id="sys.float_info.max_10_exp">1089<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">max_10_exp</span></span><a class="headerlink" href="#sys.float_info.max_10_exp" title="Link to this definition">¶</a></dt>1090<dd></dd></dl>1091 1092</td>1093<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MAX_10_EXP</span></code></p></td>1094<td><p>The maximum integer <em>e</em> such that <code class="docutils literal notranslate"><span class="pre">10**e</span></code> is in the range of1095representable finite floats.</p></td>1096</tr>1097<tr class="row-even"><td><dl class="py attribute">1098<dt class="sig sig-object py" id="sys.float_info.min">1099<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">min</span></span><a class="headerlink" href="#sys.float_info.min" title="Link to this definition">¶</a></dt>1100<dd></dd></dl>1101 1102</td>1103<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MIN</span></code></p></td>1104<td><p>The minimum representable positive <em>normalized</em> float.</p>1105<p>Use <a class="reference internal" href="math.html#math.ulp" title="math.ulp"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.ulp(0.0)</span></code></a> to get the smallest positive1106<em>denormalized</em> representable float.</p>1107</td>1108</tr>1109<tr class="row-odd"><td><dl class="py attribute">1110<dt class="sig sig-object py" id="sys.float_info.min_exp">1111<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">min_exp</span></span><a class="headerlink" href="#sys.float_info.min_exp" title="Link to this definition">¶</a></dt>1112<dd></dd></dl>1113 1114</td>1115<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MIN_EXP</span></code></p></td>1116<td><p>The minimum integer <em>e</em> such that <code class="docutils literal notranslate"><span class="pre">radix**(e-1)</span></code> is a normalized1117float.</p></td>1118</tr>1119<tr class="row-even"><td><dl class="py attribute">1120<dt class="sig sig-object py" id="sys.float_info.min_10_exp">1121<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">min_10_exp</span></span><a class="headerlink" href="#sys.float_info.min_10_exp" title="Link to this definition">¶</a></dt>1122<dd></dd></dl>1123 1124</td>1125<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">DBL_MIN_10_EXP</span></code></p></td>1126<td><p>The minimum integer <em>e</em> such that <code class="docutils literal notranslate"><span class="pre">10**e</span></code> is a normalized float.</p></td>1127</tr>1128<tr class="row-odd"><td><dl class="py attribute">1129<dt class="sig sig-object py" id="sys.float_info.radix">1130<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">radix</span></span><a class="headerlink" href="#sys.float_info.radix" title="Link to this definition">¶</a></dt>1131<dd></dd></dl>1132 1133</td>1134<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">FLT_RADIX</span></code></p></td>1135<td><p>The radix of exponent representation.</p></td>1136</tr>1137<tr class="row-even"><td><dl class="py attribute">1138<dt class="sig sig-object py" id="sys.float_info.rounds">1139<span class="sig-prename descclassname"><span class="pre">float_info.</span></span><span class="sig-name descname"><span class="pre">rounds</span></span><a class="headerlink" href="#sys.float_info.rounds" title="Link to this definition">¶</a></dt>1140<dd></dd></dl>1141 1142</td>1143<td><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">FLT_ROUNDS</span></code></p></td>1144<td><p>An integer representing the rounding mode for floating-point arithmetic.1145This reflects the value of the system <code class="xref c c-macro docutils literal notranslate"><span class="pre">FLT_ROUNDS</span></code> macro1146at interpreter startup time:</p>1147<ul class="simple">1148<li><p><code class="docutils literal notranslate"><span class="pre">-1</span></code>: indeterminable</p></li>1149<li><p><code class="docutils literal notranslate"><span class="pre">0</span></code>: toward zero</p></li>1150<li><p><code class="docutils literal notranslate"><span class="pre">1</span></code>: to nearest</p></li>1151<li><p><code class="docutils literal notranslate"><span class="pre">2</span></code>: toward positive infinity</p></li>1152<li><p><code class="docutils literal notranslate"><span class="pre">3</span></code>: toward negative infinity</p></li>1153</ul>1154<p>All other values for <code class="xref c c-macro docutils literal notranslate"><span class="pre">FLT_ROUNDS</span></code> characterize1155implementation-defined rounding behavior.</p>1156</td>1157</tr>1158</tbody>1159</table>1160<p>The attribute <a class="reference internal" href="#sys.float_info.dig" title="sys.float_info.dig"><code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.float_info.dig</span></code></a> needs further explanation. If1161<code class="docutils literal notranslate"><span class="pre">s</span></code> is any string representing a decimal number with at most1162<code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.float_info.dig</span></code> significant digits, then converting <code class="docutils literal notranslate"><span class="pre">s</span></code> to a1163float and back again will recover a string representing the same decimal1164value:</p>1165<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>1166<span class="gp">>>> </span><span class="n">sys</span><span class="o">.</span><span class="n">float_info</span><span class="o">.</span><span class="n">dig</span>1167<span class="go">15</span>1168<span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="s1">'3.14159265358979'</span> <span class="c1"># decimal string with 15 significant digits</span>1169<span class="gp">>>> </span><span class="nb">format</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">s</span><span class="p">),</span> <span class="s1">'.15g'</span><span class="p">)</span> <span class="c1"># convert to float and back -> same value</span>1170<span class="go">'3.14159265358979'</span>1171</pre></div>1172</div>1173<p>But for strings with more than <a class="reference internal" href="#sys.float_info.dig" title="sys.float_info.dig"><code class="xref py py-attr docutils literal notranslate"><span class="pre">sys.float_info.dig</span></code></a> significant digits,1174this isn’t always true:</p>1175<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="s1">'9876543211234567'</span> <span class="c1"># 16 significant digits is too many!</span>1176<span class="gp">>>> </span><span class="nb">format</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">s</span><span class="p">),</span> <span class="s1">'.16g'</span><span class="p">)</span> <span class="c1"># conversion changes value</span>1177<span class="go">'9876543211234568'</span>1178</pre></div>1179</div>1180</dd></dl>1181 1182<dl class="py data">1183<dt class="sig sig-object py" id="sys.float_repr_style">1184<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">float_repr_style</span></span><a class="headerlink" href="#sys.float_repr_style" title="Link to this definition">¶</a></dt>1185<dd><p>A string indicating how the <a class="reference internal" href="functions.html#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a> function behaves for1186floats. If the string has value <code class="docutils literal notranslate"><span class="pre">'short'</span></code> then for a finite1187float <code class="docutils literal notranslate"><span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">repr(x)</span></code> aims to produce a short string with the1188property that <code class="docutils literal notranslate"><span class="pre">float(repr(x))</span> <span class="pre">==</span> <span class="pre">x</span></code>. This is the usual behaviour1189in Python 3.1 and later. Otherwise, <code class="docutils literal notranslate"><span class="pre">float_repr_style</span></code> has value1190<code class="docutils literal notranslate"><span class="pre">'legacy'</span></code> and <code class="docutils literal notranslate"><span class="pre">repr(x)</span></code> behaves in the same way as it did in1191versions of Python prior to 3.1.</p>1192<div class="versionadded">1193<p><span class="versionmodified added">Added in version 3.1.</span></p>1194</div>1195</dd></dl>1196 1197<dl class="py function">1198<dt class="sig sig-object py" id="sys.getallocatedblocks">1199<span class="sig-prename descclassname"><span class="pre">sys.</span></span><span class="sig-name descname"><span class="pre">getallocatedblocks</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sys.getallocatedblocks" title="Link to this definition">¶</a></dt>1200<dd><p>Return the number of memory blocks currently allocated by the interpreter,