CINXE.COM

PEP 641 – Using an underscore in the version portion of Python 3.10 compatibility tags | peps.python.org

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="color-scheme" content="light dark"> <title>PEP 641 – Using an underscore in the version portion of Python 3.10 compatibility tags | peps.python.org</title> <link rel="shortcut icon" href="../_static/py.png"> <link rel="canonical" href="https://peps.python.org/pep-0641/"> <link rel="stylesheet" href="../_static/style.css" type="text/css"> <link rel="stylesheet" href="../_static/mq.css" type="text/css"> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" media="(prefers-color-scheme: light)" id="pyg-light"> <link rel="stylesheet" href="../_static/pygments_dark.css" type="text/css" media="(prefers-color-scheme: dark)" id="pyg-dark"> <link rel="alternate" type="application/rss+xml" title="Latest PEPs" href="https://peps.python.org/peps.rss"> <meta property="og:title" content='PEP 641 – Using an underscore in the version portion of Python 3.10 compatibility tags | peps.python.org'> <meta property="og:description" content="This PEP was rejected due to potential breakage in the community."> <meta property="og:type" content="website"> <meta property="og:url" content="https://peps.python.org/pep-0641/"> <meta property="og:site_name" content="Python Enhancement Proposals (PEPs)"> <meta property="og:image" content="https://peps.python.org/_static/og-image.png"> <meta property="og:image:alt" content="Python PEPs"> <meta property="og:image:width" content="200"> <meta property="og:image:height" content="200"> <meta name="description" content="This PEP was rejected due to potential breakage in the community."> <meta name="theme-color" content="#3776ab"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-sun-half" viewBox="0 0 24 24" pointer-events="all"> <title>Following system colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="9"></circle> <path d="M12 3v18m0-12l4.65-4.65M12 14.3l7.37-7.37M12 19.6l8.85-8.85"></path> </svg> </symbol> <symbol id="svg-moon" viewBox="0 0 24 24" pointer-events="all"> <title>Selected dark colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z"></path> </svg> </symbol> <symbol id="svg-sun" viewBox="0 0 24 24" pointer-events="all"> <title>Selected light colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="5"></circle> <line x1="12" y1="1" x2="12" y2="3"></line> <line x1="12" y1="21" x2="12" y2="23"></line> <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line> <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line> <line x1="1" y1="12" x2="3" y2="12"></line> <line x1="21" y1="12" x2="23" y2="12"></line> <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line> <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line> </svg> </symbol> </svg> <script> document.documentElement.dataset.colour_scheme = localStorage.getItem("colour_scheme") || "auto" </script> <section id="pep-page-section"> <header> <h1>Python Enhancement Proposals</h1> <ul class="breadcrumbs"> <li><a href="https://www.python.org/" title="The Python Programming Language">Python</a> &raquo; </li> <li><a href="../pep-0000/">PEP Index</a> &raquo; </li> <li>PEP 641</li> </ul> <button id="colour-scheme-cycler" onClick="setColourScheme(nextColourScheme())"> <svg aria-hidden="true" class="colour-scheme-icon-when-auto"><use href="#svg-sun-half"></use></svg> <svg aria-hidden="true" class="colour-scheme-icon-when-dark"><use href="#svg-moon"></use></svg> <svg aria-hidden="true" class="colour-scheme-icon-when-light"><use href="#svg-sun"></use></svg> <span class="visually-hidden">Toggle light / dark / auto colour theme</span> </button> </header> <article> <section id="pep-content"> <h1 class="page-title">PEP 641 – Using an underscore in the version portion of Python 3.10 compatibility tags</h1> <dl class="rfc2822 field-list simple"> <dt class="field-odd">Author<span class="colon">:</span></dt> <dd class="field-odd">Brett Cannon &lt;brett&#32;&#97;t&#32;python.org&gt;, Steve Dower &lt;steve.dower&#32;&#97;t&#32;python.org&gt;, Barry Warsaw &lt;barry&#32;&#97;t&#32;python.org&gt;</dd> <dt class="field-even">PEP-Delegate<span class="colon">:</span></dt> <dd class="field-even">Pablo Galindo &lt;pablogsal&#32;&#97;t&#32;python.org&gt;</dd> <dt class="field-odd">Discussions-To<span class="colon">:</span></dt> <dd class="field-odd"><a class="reference external" href="https://discuss.python.org/t/pep-641-using-an-underscore-in-the-version-portion-of-python-3-10-compatibility-tags/5513">Discourse thread</a></dd> <dt class="field-even">Status<span class="colon">:</span></dt> <dd class="field-even"><abbr title="Formally declined and will not be accepted">Rejected</abbr></dd> <dt class="field-odd">Type<span class="colon">:</span></dt> <dd class="field-odd"><abbr title="Normative PEP with a new feature for Python, implementation change for CPython or interoperability standard for the ecosystem">Standards Track</abbr></dd> <dt class="field-even">Created<span class="colon">:</span></dt> <dd class="field-even">20-Oct-2020</dd> <dt class="field-odd">Python-Version<span class="colon">:</span></dt> <dd class="field-odd">3.10</dd> <dt class="field-even">Post-History<span class="colon">:</span></dt> <dd class="field-even">21-Oct-2020</dd> <dt class="field-odd">Resolution<span class="colon">:</span></dt> <dd class="field-odd"><a class="reference external" href="https://discuss.python.org/t/pep-641-using-an-underscore-in-the-version-portion-of-python-3-10-compatibility-tags/5513/42">Discourse message</a></dd> </dl> <hr class="docutils" /> <section id="contents"> <details><summary>Table of Contents</summary><ul class="simple"> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#motivation">Motivation</a></li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#specification">Specification</a></li> <li><a class="reference internal" href="#backwards-compatibility">Backwards Compatibility</a></li> <li><a class="reference internal" href="#security-implications">Security Implications</a></li> <li><a class="reference internal" href="#how-to-teach-this">How to Teach This</a></li> <li><a class="reference internal" href="#reference-implementation">Reference Implementation</a></li> <li><a class="reference internal" href="#rejected-ideas">Rejected Ideas</a><ul> <li><a class="reference internal" href="#not-making-the-change">Not making the change</a></li> </ul> </li> <li><a class="reference internal" href="#open-issues">Open Issues</a><ul> <li><a class="reference internal" href="#how-far-should-we-take-this">How far should we take this?</a></li> <li><a class="reference internal" href="#standardizing-on-double-digit-minor-version-numbers">Standardizing on double digit minor version numbers</a></li> </ul> </li> <li><a class="reference internal" href="#references">References</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> </details></section> <section id="abstract"> <h2><a class="toc-backref" href="#abstract" role="doc-backlink">Abstract</a></h2> <div class="admonition note"> <p class="admonition-title">Note</p> <p>This PEP was rejected due to potential breakage in the community.</p> </div> <p>Using the tag system outlined in <a class="pep reference internal" href="../pep-0425/" title="PEP 425 – Compatibility Tags for Built Distributions">PEP 425</a> (primarily used for wheel file names), each release of Python specifies compatibility tags (e.g. <code class="docutils literal notranslate"><span class="pre">cp39</span></code>, <code class="docutils literal notranslate"><span class="pre">py39</span></code> for CPython 3.9). For CPython 3.10, this PEP proposes using <code class="docutils literal notranslate"><span class="pre">3_10</span></code> as the version portion of the tags (instead of <code class="docutils literal notranslate"><span class="pre">310</span></code>).</p> </section> <section id="motivation"> <h2><a class="toc-backref" href="#motivation" role="doc-backlink">Motivation</a></h2> <p>Up to this point, the version portion of compatibility tags used in e.g. wheel file names has been a straight concatenation of the major and minor versions of Python, both for the CPython interpreter tag and the generic, interpreter-agnostic interpreter tag (e.g. <code class="docutils literal notranslate"><span class="pre">cp39</span></code> and <code class="docutils literal notranslate"><span class="pre">py39</span></code>, respectively). This also applies to the ABI tag (e.g. <code class="docutils literal notranslate"><span class="pre">cp39</span></code>). Thanks to both the major and minor versions being single digits, it has been unambiguous what which digit in e.g. <code class="docutils literal notranslate"><span class="pre">39</span></code> represented.</p> <p>But starting with Python 3.10, ambiguity comes up as <code class="docutils literal notranslate"><span class="pre">310</span></code> does not clearly delineate whether the Python version is <code class="docutils literal notranslate"><span class="pre">3.10</span></code>, <code class="docutils literal notranslate"><span class="pre">31.0</span></code>, or <code class="docutils literal notranslate"><span class="pre">310</span></code> as the major-only version of Python. Thus using <code class="docutils literal notranslate"><span class="pre">3_10</span></code> to separate major/minor portions as allowed by <a class="pep reference internal" href="../pep-0425/" title="PEP 425 – Compatibility Tags for Built Distributions">PEP 425</a> disambiguates the Python version being supported.</p> </section> <section id="rationale"> <h2><a class="toc-backref" href="#rationale" role="doc-backlink">Rationale</a></h2> <p>Using <code class="docutils literal notranslate"><span class="pre">3_10</span></code> instead of another proposed separator is a restriction of <a class="pep reference internal" href="../pep-0425/" title="PEP 425 – Compatibility Tags for Built Distributions">PEP 425</a>, thus the only options are <code class="docutils literal notranslate"><span class="pre">3_10</span></code> or <code class="docutils literal notranslate"><span class="pre">310</span></code>.</p> </section> <section id="specification"> <h2><a class="toc-backref" href="#specification" role="doc-backlink">Specification</a></h2> <p>The <code class="docutils literal notranslate"><span class="pre">SOABI</span></code> configure variable and <code class="docutils literal notranslate"><span class="pre">sysconfig.get_config_var('py_version_nodot')</span></code> will be updated to use <code class="docutils literal notranslate"><span class="pre">3_10</span></code> appropriately.</p> </section> <section id="backwards-compatibility"> <h2><a class="toc-backref" href="#backwards-compatibility" role="doc-backlink">Backwards Compatibility</a></h2> <p>Tools relying on the ‘packaging’ project <a class="footnote-reference brackets" href="#id4" id="id1">[2]</a> already expect a version specification of <code class="docutils literal notranslate"><span class="pre">3_10</span></code> for Python 3.10. Keeping the version specifier as <code class="docutils literal notranslate"><span class="pre">310</span></code> would require backing that change out and updating dependent projects (e.g. pip).</p> <p>Switching to <code class="docutils literal notranslate"><span class="pre">3_10</span></code> will impact any tools that implicitly rely on the convention that the minor version is a single digit. However, these are broken regardless of any change here.</p> <p>For tools assuming the major version is only the first digit, they will require updating if we switch to <code class="docutils literal notranslate"><span class="pre">3_10</span></code>.</p> <p>In non-locale ASCII, <code class="docutils literal notranslate"><span class="pre">_</span></code> sorts after any digit, so lexicographic sorting matching a sort by Python version of a wheel file name will be kept.</p> <p>Since <a class="pep reference internal" href="../pep-0515/" title="PEP 515 – Underscores in Numeric Literals">PEP 515</a> (Python 3.6), underscores in numeric literals are ignored. This means that <code class="docutils literal notranslate"><span class="pre">int(&quot;3_10&quot;)</span></code> and <code class="docutils literal notranslate"><span class="pre">int(&quot;310&quot;)</span></code> produce the same result, and ordering based on conversion to an integer will be preserved. <strong>However</strong>, this is still a bad way to sort tags, and the point is raised here simply to show that this proposal does not make things worse.</p> </section> <section id="security-implications"> <h2><a class="toc-backref" href="#security-implications" role="doc-backlink">Security Implications</a></h2> <p>There are no known security concerns.</p> </section> <section id="how-to-teach-this"> <h2><a class="toc-backref" href="#how-to-teach-this" role="doc-backlink">How to Teach This</a></h2> <p>As use of the interpreter tag is mostly machine-based and this PEP disambiguates, there should not be any special teaching consideration required.</p> </section> <section id="reference-implementation"> <h2><a class="toc-backref" href="#reference-implementation" role="doc-backlink">Reference Implementation</a></h2> <p>A pull request <a class="footnote-reference brackets" href="#id3" id="id2">[1]</a> already exists adding support to CPython 3.10. Support for reading wheel files with this proposed PEP is already implemented.</p> </section> <section id="rejected-ideas"> <h2><a class="toc-backref" href="#rejected-ideas" role="doc-backlink">Rejected Ideas</a></h2> <section id="not-making-the-change"> <h3><a class="toc-backref" href="#not-making-the-change" role="doc-backlink">Not making the change</a></h3> <p>It was considered to not change the tag and stay with <code class="docutils literal notranslate"><span class="pre">310</span></code>. The argument was it’s less work and it won’t break any existing tooling. But in the end it was thought that the disambiguation is better to have.</p> </section> </section> <section id="open-issues"> <h2><a class="toc-backref" href="#open-issues" role="doc-backlink">Open Issues</a></h2> <section id="how-far-should-we-take-this"> <h3><a class="toc-backref" href="#how-far-should-we-take-this" role="doc-backlink">How far should we take this?</a></h3> <p>Other places where the major and minor version are used could be updated to use an underscore as well (e.g. <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files, the import path to the zip file for the stdlib). It is not known how useful it would be to make this pervasive.</p> </section> <section id="standardizing-on-double-digit-minor-version-numbers"> <h3><a class="toc-backref" href="#standardizing-on-double-digit-minor-version-numbers" role="doc-backlink">Standardizing on double digit minor version numbers</a></h3> <p>An alternative suggestion has been made to disambiguate where the major and minor versions start/stop by forcing the minor version to always be two digits, padding with a <code class="docutils literal notranslate"><span class="pre">0</span></code> as required. The advantages of this is it makes the current <code class="docutils literal notranslate"><span class="pre">cp310</span></code> interpreter tag accurate, thus minimizing breakage. It also does differentiate going forward.</p> <p>There are a couple of drawbacks, though. One is the disambiguation only exists <em>if</em> you know that the minor version number is two digits; compare that to <code class="docutils literal notranslate"><span class="pre">cp3_10</span></code> which is unambiguous regardless of your base knowledge. The potential for a three digit minor version number is also not addressed by this two digit requirement.</p> <p>There is also the issue of other interpreters not following the practice in the past, present, or future. For instance, it is unknown if other people have used a three digit version portion of the interpreter tag previously for another interpreter where this rule would be incorrect. This change would also suggest that interpreters which currently have a single digit minor version – e.g. PyPy 7.3 – to change from <code class="docutils literal notranslate"><span class="pre">pp73</span></code> to <code class="docutils literal notranslate"><span class="pre">pp703</span></code> or make the switch from their next minor release onward (e.g. 7.4 or 8.0). Otherwise this would make this rule exclusive to the <code class="docutils literal notranslate"><span class="pre">cp</span></code> interpreter type which would make it more confusing for people.</p> </section> </section> <section id="references"> <h2><a class="toc-backref" href="#references" role="doc-backlink">References</a></h2> <aside class="footnote-list brackets"> <aside class="footnote brackets" id="id3" role="doc-footnote"> <dt class="label" id="id3">[<a href="#id2">1</a>]</dt> <dd>Reference implementation (<a class="reference external" href="https://github.com/python/cpython/pull/20333">https://github.com/python/cpython/pull/20333</a>)</aside> <aside class="footnote brackets" id="id4" role="doc-footnote"> <dt class="label" id="id4">[<a href="#id1">2</a>]</dt> <dd>The ‘packaging’ project (<a class="reference external" href="https://pypi.org/project/packaging/">https://pypi.org/project/packaging/</a>)</aside> </aside> </section> <section id="copyright"> <h2><a class="toc-backref" href="#copyright" role="doc-backlink">Copyright</a></h2> <p>This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive.</p> </section> </section> <hr class="docutils" /> <p>Source: <a class="reference external" href="https://github.com/python/peps/blob/main/peps/pep-0641.rst">https://github.com/python/peps/blob/main/peps/pep-0641.rst</a></p> <p>Last modified: <a class="reference external" href="https://github.com/python/peps/commits/main/peps/pep-0641.rst">2025-02-01 08:55:40 GMT</a></p> </article> <nav id="pep-sidebar"> <h2>Contents</h2> <ul> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#motivation">Motivation</a></li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#specification">Specification</a></li> <li><a class="reference internal" href="#backwards-compatibility">Backwards Compatibility</a></li> <li><a class="reference internal" href="#security-implications">Security Implications</a></li> <li><a class="reference internal" href="#how-to-teach-this">How to Teach This</a></li> <li><a class="reference internal" href="#reference-implementation">Reference Implementation</a></li> <li><a class="reference internal" href="#rejected-ideas">Rejected Ideas</a><ul> <li><a class="reference internal" href="#not-making-the-change">Not making the change</a></li> </ul> </li> <li><a class="reference internal" href="#open-issues">Open Issues</a><ul> <li><a class="reference internal" href="#how-far-should-we-take-this">How far should we take this?</a></li> <li><a class="reference internal" href="#standardizing-on-double-digit-minor-version-numbers">Standardizing on double digit minor version numbers</a></li> </ul> </li> <li><a class="reference internal" href="#references">References</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> <br> <a id="source" href="https://github.com/python/peps/blob/main/peps/pep-0641.rst">Page Source (GitHub)</a> </nav> </section> <script src="../_static/colour_scheme.js"></script> <script src="../_static/wrap_tables.js"></script> <script src="../_static/sticky_banner.js"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10