3722 lines
430 KiB
HTML
3722 lines
430 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html lang="en" data-content_root="../">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<meta property="og:title" content="What’s new in Python 3.15" />
|
||
<meta property="og:type" content="website" />
|
||
<meta property="og:url" content="https://docs.python.org/3/whatsnew/3.15.html" />
|
||
<meta property="og:site_name" content="Python documentation" />
|
||
<meta property="og:description" content="Editor, Hugo van Kemenade,. This article explains the new features in Python 3.15, compared to 3.14. Python 3.15 was released on 9 October 2026. For full details, see the changelog. Summary – Relea..." />
|
||
<meta property="og:image" content="_static/og-image.png" />
|
||
<meta property="og:image:alt" content="Python documentation" />
|
||
<meta name="description" content="Editor, Hugo van Kemenade,. This article explains the new features in Python 3.15, compared to 3.14. Python 3.15 was released on 9 October 2026. For full details, see the changelog. Summary – Relea..." />
|
||
<meta name="theme-color" content="#3776ab">
|
||
<meta property="og:image:width" content="200">
|
||
<meta property="og:image:height" content="200">
|
||
|
||
<title>What’s new in Python 3.15 — Python 3.15.0 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=48df1187" />
|
||
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=0fc419ee" />
|
||
|
||
<script src="../_static/documentation_options.js?v=0fe728b1"></script>
|
||
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
|
||
<script src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="Search within Python 3.15.0 documentation"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="About these documents" href="../about.html" />
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
||
<link rel="next" title="What’s new in Python 3.14" href="3.14.html" />
|
||
<link rel="prev" title="What’s New in Python" href="index.html" />
|
||
|
||
|
||
<link rel="canonical" href="https://docs.python.org/3/whatsnew/3.15.html">
|
||
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg">
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||
<script type="text/javascript" src="../_static/search-focus.js"></script>
|
||
<script type="text/javascript" src="../_static/themetoggle.js"></script>
|
||
<script type="text/javascript" src="../_static/rtd_switcher.js"></script>
|
||
<meta name="readthedocs-addons-api-version" content="1">
|
||
|
||
</head>
|
||
<body>
|
||
<div class="mobile-nav">
|
||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">
|
||
<nav class="nav-content" role="navigation">
|
||
<label for="menuToggler" class="toggler__label">
|
||
<span></span>
|
||
</label>
|
||
<span class="nav-items-wrapper">
|
||
<a href="https://www.python.org/" class="nav-logo">
|
||
<img src="../_static/py.svg" alt="Python logo">
|
||
</a>
|
||
<span class="version_switcher_placeholder"></span>
|
||
<form role="search" class="search" action="../search.html" method="get">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||
<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>
|
||
</svg>
|
||
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q">
|
||
<input type="submit" value="Go">
|
||
</form>
|
||
</span>
|
||
</nav>
|
||
<div class="menu-wrapper">
|
||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||
<div class="language_switcher_placeholder"></div>
|
||
|
||
<label class="theme-selector-label">
|
||
Theme
|
||
<select class="theme-selector" oninput="activateTheme(this.value)">
|
||
<option value="auto" selected>Auto</option>
|
||
<option value="light">Light</option>
|
||
<option value="dark">Dark</option>
|
||
</select>
|
||
</label>
|
||
<div>
|
||
<h3><a href="../contents.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">What’s new in Python 3.15</a><ul>
|
||
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release highlights</a></li>
|
||
<li><a class="reference internal" href="#new-features">New features</a><ul>
|
||
<li><a class="reference internal" href="#pep-810-explicit-lazy-imports"><strong>PEP 810</strong>: Explicit lazy imports</a></li>
|
||
<li><a class="reference internal" href="#pep-814-add-frozendict-built-in-type"><strong>PEP 814</strong>: Add frozendict built-in type</a></li>
|
||
<li><a class="reference internal" href="#pep-661-add-sentinel-built-in-type"><strong>PEP 661</strong>: Add sentinel built-in type</a></li>
|
||
<li><a class="reference internal" href="#pep-799-a-dedicated-profiling-package"><strong>PEP 799</strong>: A dedicated profiling package</a></li>
|
||
<li><a class="reference internal" href="#tachyon-high-frequency-statistical-sampling-profiler">Tachyon: High-frequency statistical sampling profiler</a></li>
|
||
<li><a class="reference internal" href="#pep-831-frame-pointers-enabled-by-default"><strong>PEP 831</strong>: Frame pointers enabled by default</a></li>
|
||
<li><a class="reference internal" href="#pep-798-unpacking-in-comprehensions"><strong>PEP 798</strong>: Unpacking in comprehensions</a></li>
|
||
<li><a class="reference internal" href="#pep-829-package-startup-configuration-files"><strong>PEP 829</strong>: Package startup configuration files</a></li>
|
||
<li><a class="reference internal" href="#pep-803-stable-abi-for-free-threaded-builds"><strong>PEP 803</strong>: Stable ABI for free-threaded builds</a></li>
|
||
<li><a class="reference internal" href="#pep-788-protecting-the-c-api-from-interpreter-finalization"><strong>PEP 788</strong>: Protecting the C API from interpreter finalization</a></li>
|
||
<li><a class="reference internal" href="#improved-error-messages">Improved error messages</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#other-language-changes">Other language changes</a></li>
|
||
<li><a class="reference internal" href="#default-interactive-shell">Default interactive shell</a></li>
|
||
<li><a class="reference internal" href="#new-modules">New modules</a><ul>
|
||
<li><a class="reference internal" href="#math-integer">math.integer</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#improved-modules">Improved modules</a><ul>
|
||
<li><a class="reference internal" href="#argparse">argparse</a></li>
|
||
<li><a class="reference internal" href="#array">array</a></li>
|
||
<li><a class="reference internal" href="#ast">ast</a></li>
|
||
<li><a class="reference internal" href="#asyncio">asyncio</a></li>
|
||
<li><a class="reference internal" href="#base64">base64</a></li>
|
||
<li><a class="reference internal" href="#binascii">binascii</a></li>
|
||
<li><a class="reference internal" href="#calendar">calendar</a></li>
|
||
<li><a class="reference internal" href="#collections">collections</a></li>
|
||
<li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
|
||
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
|
||
<li><a class="reference internal" href="#ctypes">ctypes</a></li>
|
||
<li><a class="reference internal" href="#dataclasses">dataclasses</a></li>
|
||
<li><a class="reference internal" href="#dbm">dbm</a></li>
|
||
<li><a class="reference internal" href="#difflib">difflib</a></li>
|
||
<li><a class="reference internal" href="#email">email</a></li>
|
||
<li><a class="reference internal" href="#faulthandler">faulthandler</a></li>
|
||
<li><a class="reference internal" href="#functools">functools</a></li>
|
||
<li><a class="reference internal" href="#gc">gc</a></li>
|
||
<li><a class="reference internal" href="#hashlib">hashlib</a></li>
|
||
<li><a class="reference internal" href="#http-client">http.client</a></li>
|
||
<li><a class="reference internal" href="#http-server">http.server</a></li>
|
||
<li><a class="reference internal" href="#importlib-metadata">importlib.metadata</a></li>
|
||
<li><a class="reference internal" href="#inspect">inspect</a></li>
|
||
<li><a class="reference internal" href="#json">json</a></li>
|
||
<li><a class="reference internal" href="#locale">locale</a></li>
|
||
<li><a class="reference internal" href="#math">math</a></li>
|
||
<li><a class="reference internal" href="#mimetypes">mimetypes</a></li>
|
||
<li><a class="reference internal" href="#mmap">mmap</a></li>
|
||
<li><a class="reference internal" href="#os">os</a></li>
|
||
<li><a class="reference internal" href="#os-path">os.path</a></li>
|
||
<li><a class="reference internal" href="#pathlib">pathlib</a></li>
|
||
<li><a class="reference internal" href="#pdb">pdb</a></li>
|
||
<li><a class="reference internal" href="#pickle">pickle</a></li>
|
||
<li><a class="reference internal" href="#pickletools">pickletools</a></li>
|
||
<li><a class="reference internal" href="#pprint">pprint</a></li>
|
||
<li><a class="reference internal" href="#re">re</a></li>
|
||
<li><a class="reference internal" href="#resource">resource</a></li>
|
||
<li><a class="reference internal" href="#shelve">shelve</a></li>
|
||
<li><a class="reference internal" href="#socket">socket</a></li>
|
||
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
|
||
<li><a class="reference internal" href="#ssl">ssl</a></li>
|
||
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
|
||
<li><a class="reference internal" href="#symtable">symtable</a></li>
|
||
<li><a class="reference internal" href="#sys">sys</a></li>
|
||
<li><a class="reference internal" href="#sys-monitoring">sys.monitoring</a></li>
|
||
<li><a class="reference internal" href="#tarfile">tarfile</a></li>
|
||
<li><a class="reference internal" href="#threading">threading</a></li>
|
||
<li><a class="reference internal" href="#timeit">timeit</a></li>
|
||
<li><a class="reference internal" href="#tkinter">tkinter</a></li>
|
||
<li><a class="reference internal" href="#tokenize">tokenize</a></li>
|
||
<li><a class="reference internal" href="#tomllib">tomllib</a></li>
|
||
<li><a class="reference internal" href="#types">types</a></li>
|
||
<li><a class="reference internal" href="#typing">typing</a></li>
|
||
<li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
|
||
<li><a class="reference internal" href="#unittest">unittest</a></li>
|
||
<li><a class="reference internal" href="#urllib-parse">urllib.parse</a></li>
|
||
<li><a class="reference internal" href="#venv">venv</a></li>
|
||
<li><a class="reference internal" href="#warnings">warnings</a></li>
|
||
<li><a class="reference internal" href="#wave">wave</a></li>
|
||
<li><a class="reference internal" href="#webbrowser">webbrowser</a></li>
|
||
<li><a class="reference internal" href="#xml">xml</a></li>
|
||
<li><a class="reference internal" href="#xml-parsers-expat">xml.parsers.expat</a></li>
|
||
<li><a class="reference internal" href="#zlib">zlib</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#optimizations">Optimizations</a><ul>
|
||
<li><a class="reference internal" href="#base64-binascii">base64 & binascii</a></li>
|
||
<li><a class="reference internal" href="#csv">csv</a></li>
|
||
<li><a class="reference internal" href="#upgraded-experimental-jit-compiler">Upgraded experimental JIT compiler</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#removed">Removed</a><ul>
|
||
<li><a class="reference internal" href="#id1">ast</a></li>
|
||
<li><a class="reference internal" href="#collections-abc">collections.abc</a></li>
|
||
<li><a class="reference internal" href="#id2">ctypes</a></li>
|
||
<li><a class="reference internal" href="#datetime">datetime</a></li>
|
||
<li><a class="reference internal" href="#glob">glob</a></li>
|
||
<li><a class="reference internal" href="#id3">http.server</a></li>
|
||
<li><a class="reference internal" href="#importlib">importlib</a></li>
|
||
<li><a class="reference internal" href="#importlib-resources">importlib.resources</a></li>
|
||
<li><a class="reference internal" href="#id4">pathlib</a></li>
|
||
<li><a class="reference internal" href="#platform">platform</a></li>
|
||
<li><a class="reference internal" href="#sre">sre_*</a></li>
|
||
<li><a class="reference internal" href="#sysconfig">sysconfig</a></li>
|
||
<li><a class="reference internal" href="#id5">threading</a></li>
|
||
<li><a class="reference internal" href="#id6">types</a></li>
|
||
<li><a class="reference internal" href="#id7">typing</a></li>
|
||
<li><a class="reference internal" href="#id8">wave</a></li>
|
||
<li><a class="reference internal" href="#zipimport">zipimport</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#deprecated">Deprecated</a><ul>
|
||
<li><a class="reference internal" href="#new-deprecations">New deprecations</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-16">Pending removal in Python 3.16</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-17">Pending removal in Python 3.17</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-18">Pending removal in Python 3.18</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-19">Pending removal in Python 3.19</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-20">Pending removal in Python 3.20</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-future-versions">Pending removal in future versions</a></li>
|
||
<li><a class="reference internal" href="#soft-deprecations">Soft deprecations</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#c-api-changes">C API changes</a><ul>
|
||
<li><a class="reference internal" href="#id9">New features</a></li>
|
||
<li><a class="reference internal" href="#changed-c-apis">Changed C APIs</a></li>
|
||
<li><a class="reference internal" href="#removed-c-apis">Removed C APIs</a></li>
|
||
<li><a class="reference internal" href="#deprecated-c-apis">Deprecated C APIs</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#build-changes">Build changes</a></li>
|
||
<li><a class="reference internal" href="#porting-to-python-3-15">Porting to Python 3.15</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="index.html"
|
||
title="previous chapter">What’s New in Python</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="3.14.html"
|
||
title="next chapter">What’s new in Python 3.14</a></p>
|
||
</div>
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
const title = document.querySelector('meta[property="og:title"]').content;
|
||
const elements = document.querySelectorAll('.improvepage');
|
||
const pageurl = window.location.href.split('?')[0];
|
||
elements.forEach(element => {
|
||
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
|
||
url.searchParams.set('pagetitle', title);
|
||
url.searchParams.set('pageurl', pageurl);
|
||
url.searchParams.set('pagesource', "whatsnew/3.15.rst");
|
||
element.href = url.toString();
|
||
});
|
||
});
|
||
</script>
|
||
<div role="note" aria-label="source link">
|
||
<h3>This page</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">Report a bug</a></li>
|
||
<li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.15/Doc/whatsnew/3.15.rst?plain=1"
|
||
rel="nofollow">Show source
|
||
</a>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="3.14.html" title="What’s new in Python 3.14"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="index.html" title="What’s New in Python"
|
||
accesskey="P">previous</a> |</li>
|
||
|
||
<li class="root-icon"><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.15.0 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">What’s new in Python 3.15</a></li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
|
||
<input type="submit" value="Go">
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
<li class="right">
|
||
<label class="theme-selector-label">
|
||
Theme
|
||
<select class="theme-selector" oninput="activateTheme(this.value)">
|
||
<option value="auto" selected>Auto</option>
|
||
<option value="light">Light</option>
|
||
<option value="dark">Dark</option>
|
||
</select>
|
||
</label> |</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="what-s-new-in-python-3-15">
|
||
<h1>What’s new in Python 3.15<a class="headerlink" href="#what-s-new-in-python-3-15" title="Link to this heading">¶</a></h1>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Editor<span class="colon">:</span></dt>
|
||
<dd class="field-odd"><p>Hugo van Kemenade</p>
|
||
</dd>
|
||
</dl>
|
||
<p>This article explains the new features in Python 3.15, compared to 3.14.
|
||
Python 3.15 was released on 9 October 2026.
|
||
For full details, see the <a class="reference internal" href="changelog.html#changelog"><span class="std std-ref">changelog</span></a>.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0790/"><strong>PEP 790</strong></a> – Python 3.15 release schedule</p>
|
||
</div>
|
||
<section id="summary-release-highlights">
|
||
<h2>Summary – Release highlights<a class="headerlink" href="#summary-release-highlights" title="Link to this heading">¶</a></h2>
|
||
<p>Python 3.15 is the latest stable release of the Python programming
|
||
language, with a mix of changes to the language, the implementation,
|
||
and the standard library.
|
||
The biggest changes include
|
||
<a class="reference internal" href="#whatsnew315-lazy-imports"><span class="std std-ref">lazy imports</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-frozendict"><span class="std std-ref">frozendict</span></a> and
|
||
<a class="reference internal" href="#whatsnew315-sentinel"><span class="std std-ref">sentinel</span></a> builtins,
|
||
<a class="reference internal" href="#whatsnew315-utf8-default"><span class="std std-ref">UTF-8 as the default encoding</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-unpacking-in-comprehensions"><span class="std std-ref">unpacking in comprehensions</span></a>,
|
||
and a <a class="reference internal" href="#whatsnew315-abi3t"><span class="std std-ref">stable ABI for free-threaded builds</span></a>.</p>
|
||
<p>The library changes include a new
|
||
<a class="reference internal" href="#whatsnew315-profiling-package"><span class="std std-ref">profiling package</span></a> with
|
||
<a class="reference internal" href="#whatsnew315-sampling-profiler"><span class="std std-ref">Tachyon</span></a>,
|
||
a high-frequency statistical sampling profiler,
|
||
<a class="reference internal" href="#whatsnew315-more-color"><span class="std std-ref">more color</span></a> in command-line output,
|
||
as well as the usual deprecations and removals,
|
||
and improvements in user-friendliness and correctness.</p>
|
||
<p>This article doesn’t attempt to provide a complete specification
|
||
of all new features, but instead gives a convenient overview.
|
||
For full details refer to the documentation,
|
||
such as the <a class="reference internal" href="../library/index.html#library-index"><span class="std std-ref">Library Reference</span></a>
|
||
and <a class="reference internal" href="../reference/index.html#reference-index"><span class="std std-ref">Language Reference</span></a>.
|
||
To understand the complete implementation and design rationale for a change,
|
||
refer to the PEP for a particular new feature;
|
||
but note that PEPs usually are not kept up-to-date
|
||
once a feature has been fully implemented.</p>
|
||
<p>See <a class="reference internal" href="#porting-to-python-3-15">Porting to Python 3.15</a> for guidance on upgrading from
|
||
earlier versions of Python.</p>
|
||
<hr class="docutils" />
|
||
<p>Interpreter improvements:</p>
|
||
<ul class="simple">
|
||
<li><p><span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0661/"><strong>PEP 661</strong></a>: <a class="reference internal" href="#whatsnew315-sentinel"><span class="std std-ref">Add sentinel built-in type</span></a></p></li>
|
||
<li><p><span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-0686/"><strong>PEP 686</strong></a>: <a class="reference internal" href="#whatsnew315-utf8-default"><span class="std std-ref">Python now uses UTF-8 as the default encoding</span></a></p></li>
|
||
<li><p><span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0798/"><strong>PEP 798</strong></a>: <a class="reference internal" href="#whatsnew315-unpacking-in-comprehensions"><span class="std std-ref">Unpacking in comprehensions</span></a></p></li>
|
||
<li><p><span class="target" id="index-4"></span><a class="pep reference external" href="https://peps.python.org/pep-0810/"><strong>PEP 810</strong></a>: <a class="reference internal" href="#whatsnew315-lazy-imports"><span class="std std-ref">Explicit lazy imports for faster startup times</span></a></p></li>
|
||
<li><p><span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-0814/"><strong>PEP 814</strong></a>: <a class="reference internal" href="#whatsnew315-frozendict"><span class="std std-ref">Add frozendict built-in type</span></a></p></li>
|
||
<li><p><span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-0829/"><strong>PEP 829</strong></a>: <a class="reference internal" href="#whatsnew315-startup-files"><span class="std std-ref">Package startup configuration files</span></a></p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew315-jit"><span class="std std-ref">The experimental JIT compiler has been significantly upgraded</span></a></p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew315-improved-error-messages"><span class="std std-ref">Improved error messages</span></a></p></li>
|
||
</ul>
|
||
<p>Significant improvements in the standard library:</p>
|
||
<ul class="simple">
|
||
<li><p><span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0799/"><strong>PEP 799</strong></a>: <a class="reference internal" href="#whatsnew315-profiling-package"><span class="std std-ref">A dedicated profiling package for organizing Python
|
||
profiling tools</span></a></p></li>
|
||
<li><p><span class="target" id="index-8"></span><a class="pep reference external" href="https://peps.python.org/pep-0799/"><strong>PEP 799</strong></a>: <a class="reference internal" href="#whatsnew315-sampling-profiler"><span class="std std-ref">Tachyon: High-frequency statistical sampling profiler</span></a></p></li>
|
||
<li><p><a class="reference internal" href="#whatsnew315-more-color"><span class="std std-ref">More color</span></a></p></li>
|
||
</ul>
|
||
<p>New typing features:</p>
|
||
<ul class="simple">
|
||
<li><p><span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-0728/"><strong>PEP 728</strong></a>: <a class="reference internal" href="#whatsnew315-typeddict"><span class="std std-ref">TypedDict with typed extra items</span></a></p></li>
|
||
<li><p><span class="target" id="index-10"></span><a class="pep reference external" href="https://peps.python.org/pep-0747/"><strong>PEP 747</strong></a>: <a class="reference internal" href="#whatsnew315-typeform"><span class="std std-ref">Annotating type forms with TypeForm</span></a></p></li>
|
||
<li><p><span class="target" id="index-11"></span><a class="pep reference external" href="https://peps.python.org/pep-0800/"><strong>PEP 800</strong></a>: <a class="reference internal" href="#whatsnew315-disjoint-base"><span class="std std-ref">Disjoint bases in the type system</span></a></p></li>
|
||
</ul>
|
||
<p>C API improvements:</p>
|
||
<ul class="simple">
|
||
<li><p><span class="target" id="index-12"></span><a class="pep reference external" href="https://peps.python.org/pep-0782/"><strong>PEP 782</strong></a>: <a class="reference internal" href="#whatsnew315-pybyteswriter"><span class="std std-ref">A new PyBytesWriter C API to create a Python bytes object</span></a></p></li>
|
||
<li><p><span class="target" id="index-13"></span><a class="pep reference external" href="https://peps.python.org/pep-0788/"><strong>PEP 788</strong></a>: <a class="reference internal" href="#whatsnew315-c-api-interpreter-finalization"><span class="std std-ref">Protection against finalization in the C API</span></a></p></li>
|
||
<li><p><span class="target" id="index-14"></span><a class="pep reference external" href="https://peps.python.org/pep-0803/"><strong>PEP 803</strong></a>, <span class="target" id="index-15"></span><a class="pep reference external" href="https://peps.python.org/pep-0820/"><strong>820</strong></a>, <span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0793/"><strong>793</strong></a>:
|
||
<a class="reference internal" href="#whatsnew315-abi3t"><span class="std std-ref">Stable ABI for free-threaded builds</span></a> and
|
||
related C API</p></li>
|
||
</ul>
|
||
<p>Build changes:</p>
|
||
<ul class="simple">
|
||
<li><p><span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-0831/"><strong>PEP 831</strong></a>: <a class="reference internal" href="#whatsnew315-frame-pointers"><span class="std std-ref">Frame pointers are enabled by default for improved
|
||
system-level observability</span></a></p></li>
|
||
</ul>
|
||
<p>Release changes:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="#whatsnew315-windows-tail-calling-interpreter"><span class="std std-ref">The official Windows 64-bit binaries now use the tail-calling interpreter</span></a></p></li>
|
||
<li><p>The official macOS binaries now install free-threading support by default</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="new-features">
|
||
<h2>New features<a class="headerlink" href="#new-features" title="Link to this heading">¶</a></h2>
|
||
<section id="pep-810-explicit-lazy-imports">
|
||
<span id="whatsnew315-lazy-imports"></span><h3><span class="target" id="index-18"></span><a class="pep reference external" href="https://peps.python.org/pep-0810/"><strong>PEP 810</strong></a>: Explicit lazy imports<a class="headerlink" href="#pep-810-explicit-lazy-imports" title="Link to this heading">¶</a></h3>
|
||
<p>Large Python applications often suffer from slow startup times. A
|
||
significant contributor to this problem is the import system: when a module
|
||
is imported, Python must locate the file, read it from disk, compile it to
|
||
bytecode, and execute all top-level code. For applications with deep
|
||
dependency trees, this process can take seconds, even when most of the
|
||
imported code is never actually used during a particular run.</p>
|
||
<p>Developers have worked around this by moving imports inside functions, using
|
||
<a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a> to load modules on demand, or restructuring code to avoid
|
||
unnecessary dependencies. These approaches work but make code harder to read
|
||
and maintain, scatter import statements throughout the codebase, and require
|
||
discipline to apply consistently.</p>
|
||
<p>Python now provides a cleaner solution through explicit <a class="reference internal" href="../reference/simple_stmts.html#lazy"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">lazy</span></code></a>
|
||
imports using the new <code class="docutils literal notranslate"><span class="pre">lazy</span></code> soft keyword. When you mark an import as
|
||
lazy, Python defers the actual module loading until the imported name is
|
||
first used. This gives you the organizational benefits of declaring all
|
||
imports at the top of the file while only paying the loading cost for
|
||
modules you actually use.</p>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">lazy</span></code> keyword works with both <code class="docutils literal notranslate"><span class="pre">import</span></code> and <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span></code>
|
||
statements. When you write <code class="docutils literal notranslate"><span class="pre">lazy</span> <span class="pre">import</span> <span class="pre">heavy_module</span></code>, Python does not
|
||
immediately load the module. Instead, it creates a lightweight proxy object.
|
||
The actual module loading happens transparently when you first access the
|
||
name:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">lazy</span><span class="w"> </span><span class="kn">import</span><span class="w"> </span><span class="nn">json</span>
|
||
<span class="kn">lazy</span><span class="w"> </span><span class="kn">from</span><span class="w"> </span><span class="nn">pathlib</span><span class="w"> </span><span class="kn">import</span> <span class="n">Path</span>
|
||
|
||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Starting up..."</span><span class="p">)</span> <span class="c1"># json and pathlib are not fully imported yet</span>
|
||
|
||
<span class="n">data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="s1">'{"key": "value"}'</span><span class="p">)</span> <span class="c1"># json gets fully imported here</span>
|
||
<span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s2">"."</span><span class="p">)</span> <span class="c1"># pathlib gets fully imported here</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This mechanism is particularly useful for applications that import many
|
||
modules at the top level but may only use a subset of them in any given run.
|
||
The deferred loading reduces startup latency without requiring code
|
||
restructuring or conditional imports scattered throughout the codebase.</p>
|
||
<p>In the case where loading a lazily imported module fails (for example, if
|
||
the module does not exist), Python raises the exception at the point of
|
||
first use rather than at import time. The associated traceback includes both
|
||
the location where the name was accessed and the original import statement,
|
||
making it straightforward to diagnose and debug the failure.</p>
|
||
<p>For cases where you want to enable lazy loading globally without modifying
|
||
source code, Python provides 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> <span class="pre">lazy_imports</span></code></a> command-line
|
||
option and the <span class="target" id="index-19"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHON_LAZY_IMPORTS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_LAZY_IMPORTS</span></code></a> environment variable. Both
|
||
accept two values: <code class="docutils literal notranslate"><span class="pre">all</span></code> makes all imports lazy by default, and <code class="docutils literal notranslate"><span class="pre">normal</span></code>
|
||
(the default) respects the <code class="docutils literal notranslate"><span class="pre">lazy</span></code> keyword in source code. The
|
||
<a class="reference internal" href="../library/sys.html#sys.set_lazy_imports" title="sys.set_lazy_imports"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_lazy_imports()</span></code></a> and <a class="reference internal" href="../library/sys.html#sys.get_lazy_imports" title="sys.get_lazy_imports"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.get_lazy_imports()</span></code></a> functions allow
|
||
changing and querying this mode at runtime.</p>
|
||
<p>For more selective control, <a class="reference internal" href="../library/sys.html#sys.set_lazy_imports_filter" title="sys.set_lazy_imports_filter"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.set_lazy_imports_filter()</span></code></a> accepts a
|
||
callable that determines whether a specific module should be loaded lazily.
|
||
The filter receives three arguments: the importing module’s name (or
|
||
<code class="docutils literal notranslate"><span class="pre">None</span></code>), the imported module’s name, and the fromlist (or <code class="docutils literal notranslate"><span class="pre">None</span></code> for
|
||
regular imports). It should return <code class="docutils literal notranslate"><span class="pre">True</span></code> to allow the import to be lazy,
|
||
or <code class="docutils literal notranslate"><span class="pre">False</span></code> to force eager loading. This allows patterns like making only
|
||
your own application’s modules lazy while keeping third-party dependencies
|
||
eager:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>
|
||
|
||
<span class="k">def</span><span class="w"> </span><span class="nf">myapp_filter</span><span class="p">(</span><span class="n">importing</span><span class="p">,</span> <span class="n">imported</span><span class="p">,</span> <span class="n">fromlist</span><span class="p">):</span>
|
||
<span class="k">return</span> <span class="n">imported</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"myapp."</span><span class="p">)</span>
|
||
<span class="n">sys</span><span class="o">.</span><span class="n">set_lazy_imports_filter</span><span class="p">(</span><span class="n">myapp_filter</span><span class="p">)</span>
|
||
<span class="n">sys</span><span class="o">.</span><span class="n">set_lazy_imports</span><span class="p">(</span><span class="s2">"all"</span><span class="p">)</span>
|
||
|
||
<span class="kn">import</span><span class="w"> </span><span class="nn">myapp.slow_module</span> <span class="c1"># lazy (matches filter)</span>
|
||
<span class="kn">import</span><span class="w"> </span><span class="nn">json</span> <span class="c1"># eager (does not match filter)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The proxy type itself is available as <a class="reference internal" href="../library/types.html#types.LazyImportType" title="types.LazyImportType"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.LazyImportType</span></code></a> for code
|
||
that needs to detect lazy imports programmatically.</p>
|
||
<p>There are some restrictions on where the <code class="docutils literal notranslate"><span class="pre">lazy</span></code> keyword can be used. Lazy
|
||
imports are only permitted at module scope; using <code class="docutils literal notranslate"><span class="pre">lazy</span></code> inside a
|
||
function, class body, or <code class="docutils literal notranslate"><span class="pre">try</span></code>/<code class="docutils literal notranslate"><span class="pre">except</span></code>/<code class="docutils literal notranslate"><span class="pre">finally</span></code> block raises a
|
||
<a class="reference internal" href="../builtins/exceptions.html#SyntaxError" title="SyntaxError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code></a>. Neither star imports nor future imports can be lazy
|
||
(<code class="docutils literal notranslate"><span class="pre">lazy</span> <span class="pre">from</span> <span class="pre">module</span> <span class="pre">import</span> <span class="pre">*</span></code> and <code class="docutils literal notranslate"><span class="pre">lazy</span> <span class="pre">from</span> <span class="pre">__future__</span> <span class="pre">import</span> <span class="pre">...</span></code> both
|
||
raise <code class="xref py py-exc docutils literal notranslate"><span class="pre">SyntaxError</span></code>).</p>
|
||
<p>For code that cannot use the <code class="docutils literal notranslate"><span class="pre">lazy</span></code> keyword directly (for example, when
|
||
supporting Python versions older than 3.15 while still using lazy
|
||
imports on 3.15+), a module can define
|
||
<a class="reference internal" href="../reference/datamodel.html#module.__lazy_modules__" title="module.__lazy_modules__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__lazy_modules__</span></code></a> as a container of fully qualified module
|
||
name strings. Regular <code class="docutils literal notranslate"><span class="pre">import</span></code> statements for those modules are then treated
|
||
as lazy, with the same semantics as the <code class="docutils literal notranslate"><span class="pre">lazy</span></code> keyword:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">__lazy_modules__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"json"</span><span class="p">,</span> <span class="s2">"pathlib"</span><span class="p">]</span>
|
||
|
||
<span class="kn">import</span><span class="w"> </span><span class="nn">json</span> <span class="c1"># lazy</span>
|
||
<span class="kn">import</span><span class="w"> </span><span class="nn">os</span> <span class="c1"># still eager</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Pablo Galindo Salgado and Dino Viehland in <a class="reference external" href="https://github.com/python/cpython/issues/142349">gh-142349</a>.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-20"></span><a class="pep reference external" href="https://peps.python.org/pep-0810/"><strong>PEP 810</strong></a> for the full specification and rationale.</p>
|
||
</div>
|
||
</section>
|
||
<section id="pep-814-add-frozendict-built-in-type">
|
||
<span id="whatsnew315-frozendict"></span><h3><span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0814/"><strong>PEP 814</strong></a>: Add frozendict built-in type<a class="headerlink" href="#pep-814-add-frozendict-built-in-type" title="Link to this heading">¶</a></h3>
|
||
<p>A new <a class="reference internal" href="../glossary.html#term-immutable"><span class="xref std std-term">immutable</span></a> type, <a class="reference internal" href="../builtins/stdtypes.html#frozendict" title="frozendict"><code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code></a>, is added to the <a class="reference internal" href="../library/builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code></a> module.
|
||
It does not allow modification after creation. A <code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code> is not a subclass of <code class="docutils literal notranslate"><span class="pre">dict</span></code>;
|
||
it inherits directly from <code class="docutils literal notranslate"><span class="pre">object</span></code>. A <code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code> is <a class="reference internal" href="../glossary.html#term-hashable"><span class="xref std std-term">hashable</span></a>
|
||
as long as all of its keys and values are hashable. A <code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code> preserves
|
||
insertion order, but comparison does not take order into account.</p>
|
||
<p>For example:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="nb">frozendict</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="n">a</span>
|
||
<span class="go">frozendict({'x': 1, 'y': 2})</span>
|
||
<span class="gp">>>> </span><span class="n">a</span><span class="p">[</span><span class="s1">'z'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
File <span class="nb">"<python-input-2>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
|
||
<span class="w"> </span><span class="n">a</span><span class="p">[</span><span class="s1">'z'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span>
|
||
<span class="w"> </span><span class="pm">~^^^^^</span>
|
||
<span class="gr">TypeError</span>: <span class="n">'frozendict' object does not support item assignment</span>
|
||
<span class="gp">>>> </span><span class="n">b</span> <span class="o">=</span> <span class="nb">frozendict</span><span class="p">(</span><span class="n">y</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">x</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
|
||
<span class="gp">>>> </span><span class="nb">hash</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="o">==</span> <span class="nb">hash</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
|
||
<span class="go">True</span>
|
||
<span class="gp">>>> </span><span class="n">a</span> <span class="o">==</span> <span class="n">b</span>
|
||
<span class="go">True</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>The following standard library modules have been updated to accept
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code>: <a class="reference internal" href="../library/copy.html#module-copy" title="copy: Shallow and deep copy operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">copy</span></code></a>, <a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a>, <a class="reference internal" href="../library/json.html#module-json" title="json: Encode and decode the JSON format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code></a>, <a class="reference internal" href="../library/marshal.html#module-marshal" title="marshal: Convert Python objects to streams of bytes and back (with different constraints)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">marshal</span></code></a>,
|
||
<a class="reference internal" href="../library/plistlib.html#module-plistlib" title="plistlib: Generate and parse Apple plist files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">plistlib</span></code></a> (only for serialization), <a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a>, <a class="reference internal" href="../library/pprint.html#module-pprint" title="pprint: Data pretty printer."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pprint</span></code></a> and
|
||
<a class="reference internal" href="../library/xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code></a>.</p>
|
||
<p><a class="reference internal" href="../builtins/functions.html#eval" title="eval"><code class="xref py py-func docutils literal notranslate"><span class="pre">eval()</span></code></a> and <a class="reference internal" href="../builtins/functions.html#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a> accept <code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code> for <em>globals</em>, and
|
||
<a class="reference internal" href="../builtins/functions.html#type" title="type"><code class="xref py py-func docutils literal notranslate"><span class="pre">type()</span></code></a> and <a class="reference internal" href="../builtins/stdtypes.html#str.maketrans" title="str.maketrans"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.maketrans()</span></code></a> accept <code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code> for <em>dict</em>.</p>
|
||
<p>Code checking for <a class="reference internal" href="../builtins/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> type using <code class="docutils literal notranslate"><span class="pre">isinstance(arg,</span> <span class="pre">dict)</span></code> can be
|
||
updated to <code class="docutils literal notranslate"><span class="pre">isinstance(arg,</span> <span class="pre">(dict,</span> <span class="pre">frozendict))</span></code> to accept also the
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code> type, or to <code class="docutils literal notranslate"><span class="pre">isinstance(arg,</span> <span class="pre">collections.abc.Mapping)</span></code>
|
||
to accept also other mapping types such as <a class="reference internal" href="../library/types.html#types.MappingProxyType" title="types.MappingProxyType"><code class="xref py py-class docutils literal notranslate"><span class="pre">MappingProxyType</span></code></a>.</p>
|
||
<p>(Contributed by Victor Stinner and Donghee Na in <a class="reference external" href="https://github.com/python/cpython/issues/141510">gh-141510</a>.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-22"></span><a class="pep reference external" href="https://peps.python.org/pep-0814/"><strong>PEP 814</strong></a> for the full specification and rationale.</p>
|
||
</div>
|
||
</section>
|
||
<section id="pep-661-add-sentinel-built-in-type">
|
||
<span id="whatsnew315-sentinel"></span><h3><span class="target" id="index-23"></span><a class="pep reference external" href="https://peps.python.org/pep-0661/"><strong>PEP 661</strong></a>: Add sentinel built-in type<a class="headerlink" href="#pep-661-add-sentinel-built-in-type" title="Link to this heading">¶</a></h3>
|
||
<p>A new <a class="reference internal" href="../builtins/functions.html#sentinel" title="sentinel"><code class="xref py py-class docutils literal notranslate"><span class="pre">sentinel</span></code></a> type is added to the <a class="reference internal" href="../library/builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code></a> module for
|
||
creating unique sentinel values with a concise representation. Sentinel
|
||
objects preserve identity when copied, support use in type expressions with
|
||
the <code class="docutils literal notranslate"><span class="pre">|</span></code> operator, and can be pickled when they are importable by module and
|
||
name.</p>
|
||
<p>(Contributed by Jelle Zijlstra in <a class="reference external" href="https://github.com/python/cpython/issues/148829">gh-148829</a>; PEP 661 written by Tal Einat.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-24"></span><a class="pep reference external" href="https://peps.python.org/pep-0661/"><strong>PEP 661</strong></a> for further details.</p>
|
||
</div>
|
||
</section>
|
||
<section id="pep-799-a-dedicated-profiling-package">
|
||
<span id="whatsnew315-profiling-package"></span><h3><span class="target" id="index-25"></span><a class="pep reference external" href="https://peps.python.org/pep-0799/"><strong>PEP 799</strong></a>: A dedicated profiling package<a class="headerlink" href="#pep-799-a-dedicated-profiling-package" title="Link to this heading">¶</a></h3>
|
||
<p>A new <a class="reference internal" href="../library/profiling.html#module-profiling" title="profiling: Python profiling tools for performance analysis."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling</span></code></a> module has been added to organize Python’s built-in
|
||
profiling tools under a single, coherent namespace. This module contains:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/profiling.tracing.html#module-profiling.tracing" title="profiling.tracing: Deterministic tracing profiler for Python programs."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.tracing</span></code></a>: deterministic function-call tracing (relocated from
|
||
<code class="docutils literal notranslate"><span class="pre">cProfile</span></code>).</p></li>
|
||
<li><p><a class="reference internal" href="../library/profiling.sampling.html#module-profiling.sampling" title="profiling.sampling: Statistical sampling profiler for Python processes."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.sampling</span></code></a>: a new statistical sampling profiler (named Tachyon).</p></li>
|
||
</ul>
|
||
<p>The <code class="docutils literal notranslate"><span class="pre">cProfile</span></code> module remains as an alias for backwards compatibility.
|
||
The <a class="reference internal" href="../library/profile.html#module-profile" title="profile: Pure Python profiler (deprecated). (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code></a> module is deprecated and will be removed in Python 3.17.</p>
|
||
<p>(Contributed by Pablo Galindo and László Kiss Kollár in <a class="reference external" href="https://github.com/python/cpython/issues/138122">gh-138122</a>.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-26"></span><a class="pep reference external" href="https://peps.python.org/pep-0799/"><strong>PEP 799</strong></a> for further details.</p>
|
||
</div>
|
||
</section>
|
||
<section id="tachyon-high-frequency-statistical-sampling-profiler">
|
||
<span id="whatsnew315-sampling-profiler"></span><h3>Tachyon: High-frequency statistical sampling profiler<a class="headerlink" href="#tachyon-high-frequency-statistical-sampling-profiler" title="Link to this heading">¶</a></h3>
|
||
<img alt="Tachyon profiler logo" class="no-scaled-link align-center" src="../_images/tachyon-logo.png" style="width: 200px;" />
|
||
<p>A new statistical sampling profiler (Tachyon) has been added as
|
||
<a class="reference internal" href="../library/profiling.sampling.html#module-profiling.sampling" title="profiling.sampling: Statistical sampling profiler for Python processes."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.sampling</span></code></a>. This profiler enables low-overhead performance analysis of
|
||
running Python processes without requiring code modification or process restart.</p>
|
||
<p>Unlike deterministic profilers (such as <a class="reference internal" href="../library/profiling.tracing.html#module-profiling.tracing" title="profiling.tracing: Deterministic tracing profiler for Python programs."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.tracing</span></code></a>) that instrument
|
||
every function call, the sampling profiler periodically captures stack traces from
|
||
running processes. This approach provides virtually zero overhead while achieving
|
||
sampling rates of <strong>up to 1,000,000 Hz</strong>, making it the fastest sampling profiler
|
||
available for Python (at the time of its contribution) and ideal for debugging
|
||
performance issues in production environments. This capability is particularly
|
||
valuable for debugging performance issues in production systems where traditional
|
||
profiling approaches would be too intrusive.</p>
|
||
<p>Key features include:</p>
|
||
<ul class="simple">
|
||
<li><p><strong>Zero-overhead profiling</strong>: Attach to any running Python process without
|
||
affecting its performance. Ideal for production debugging where you can’t afford
|
||
to restart or slow down your application.</p></li>
|
||
<li><p><strong>No code modification required</strong>: Profile existing applications without restart.
|
||
Simply point the profiler at a running process by PID and start collecting data.</p></li>
|
||
<li><p><strong>Flexible target modes</strong>:</p>
|
||
<ul>
|
||
<li><p>Profile running processes by PID (<code class="docutils literal notranslate"><span class="pre">attach</span></code>) - attach to already-running applications</p></li>
|
||
<li><p>Run and profile scripts directly (<code class="docutils literal notranslate"><span class="pre">run</span></code>) - profile from the very start of execution</p></li>
|
||
<li><p>Execute and profile modules (<code class="docutils literal notranslate"><span class="pre">run</span> <span class="pre">-m</span></code>) - profile packages run as <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">module</span></code></p></li>
|
||
<li><p>Capture a one-shot snapshot of a running process (<code class="docutils literal notranslate"><span class="pre">dump</span></code>) - print a
|
||
traceback-style stack of every thread (or all asyncio tasks with
|
||
<code class="docutils literal notranslate"><span class="pre">--async-aware</span></code>). Useful for investigating hung processes.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><strong>Multiple profiling modes</strong>: Choose what to measure based on your performance investigation:</p>
|
||
<ul>
|
||
<li><p><strong>Wall-clock time</strong> (<code class="docutils literal notranslate"><span class="pre">--mode</span> <span class="pre">wall</span></code>, default): Measures real elapsed time including I/O,
|
||
network waits, and blocking operations. Use this to understand where your program spends
|
||
calendar time, including when waiting for external resources.</p></li>
|
||
<li><p><strong>CPU time</strong> (<code class="docutils literal notranslate"><span class="pre">--mode</span> <span class="pre">cpu</span></code>): Measures only active CPU execution time, excluding I/O waits
|
||
and blocking. Use this to identify CPU-bound bottlenecks and optimize computational work.</p></li>
|
||
<li><p><strong>GIL-holding time</strong> (<code class="docutils literal notranslate"><span class="pre">--mode</span> <span class="pre">gil</span></code>): Measures time spent holding Python’s Global Interpreter
|
||
Lock. Use this to identify which threads dominate GIL usage in multi-threaded applications.</p></li>
|
||
<li><p><strong>Exception handling time</strong> (<code class="docutils literal notranslate"><span class="pre">--mode</span> <span class="pre">exception</span></code>): Captures samples only from threads with
|
||
an active exception. Use this to analyze exception handling overhead.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><strong>Thread-aware profiling</strong>: Option to profile all threads (<code class="docutils literal notranslate"><span class="pre">-a</span></code>) or just the main thread,
|
||
essential for understanding multi-threaded application behavior.</p></li>
|
||
<li><p><strong>Multiple output formats</strong>: Choose the visualization that best fits your workflow:</p>
|
||
<ul>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">--pstats</span></code>: Detailed tabular statistics compatible with <a class="reference internal" href="../library/pstats.html#module-pstats" title="pstats: Statistics object for analyzing profiler output."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pstats</span></code></a>. Shows function-level
|
||
timing with direct and cumulative samples. Best for detailed analysis and integration with
|
||
existing Python profiling tools.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">--collapsed</span></code>: Generates collapsed stack traces (one line per stack). This format is
|
||
specifically designed for creating flame graphs with external tools like Brendan Gregg’s
|
||
FlameGraph scripts or speedscope.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">--flamegraph</span></code>: Generates a self-contained interactive HTML flame graph using D3.js.
|
||
Opens directly in your browser for immediate visual analysis. Flame graphs show the call
|
||
hierarchy where width represents time spent, making it easy to spot bottlenecks at a glance.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">--gecko</span></code>: Generates Gecko Profiler format compatible with <a class="reference external" href="https://profiler.firefox.com">Firefox Profiler</a>. Upload the output to Firefox Profiler for advanced
|
||
timeline-based analysis with features like stack charts, markers, and network activity.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">--heatmap</span></code>: Generates an interactive HTML heatmap visualization with line-level sample
|
||
counts. Creates a directory with per-file heatmaps showing exactly where time is spent
|
||
at the source code level.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><strong>Live interactive mode</strong>: Real-time TUI profiler with a top-like interface (<code class="docutils literal notranslate"><span class="pre">--live</span></code>).
|
||
Monitor performance as your application runs with interactive sorting and filtering.</p></li>
|
||
<li><p><strong>Async-aware profiling</strong>: Profile async/await code with task-based stack reconstruction
|
||
(<code class="docutils literal notranslate"><span class="pre">--async-aware</span></code>). See which coroutines are consuming time, with options to show only
|
||
running tasks or all tasks including those waiting.</p></li>
|
||
<li><p><strong>Opcode-level profiling</strong>: Gather bytecode opcode information for instruction-level
|
||
profiling (<code class="docutils literal notranslate"><span class="pre">--opcodes</span></code>). Shows which bytecode instructions are executing, including
|
||
specializations from the adaptive interpreter.</p></li>
|
||
</ul>
|
||
<p>See <a class="reference internal" href="../library/profiling.sampling.html#module-profiling.sampling" title="profiling.sampling: Statistical sampling profiler for Python processes."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.sampling</span></code></a> for the complete documentation, including all
|
||
available output formats, profiling modes, and configuration options.</p>
|
||
<p>(Contributed by Pablo Galindo and László Kiss Kollár in <a class="reference external" href="https://github.com/python/cpython/issues/135953">gh-135953</a> and <a class="reference external" href="https://github.com/python/cpython/issues/138122">gh-138122</a>.)</p>
|
||
</section>
|
||
<section id="pep-831-frame-pointers-enabled-by-default">
|
||
<span id="whatsnew315-frame-pointers"></span><h3><span class="target" id="index-27"></span><a class="pep reference external" href="https://peps.python.org/pep-0831/"><strong>PEP 831</strong></a>: Frame pointers enabled by default<a class="headerlink" href="#pep-831-frame-pointers-enabled-by-default" title="Link to this heading">¶</a></h3>
|
||
<p>CPython is now built with frame pointers by default on platforms that support
|
||
them. This uses the compiler flags <code class="docutils literal notranslate"><span class="pre">-fno-omit-frame-pointer</span></code> and
|
||
<code class="docutils literal notranslate"><span class="pre">-mno-omit-leaf-frame-pointer</span></code>, making native stack unwinding faster and
|
||
more reliable for system profilers, debuggers, crash analysis tools, and
|
||
eBPF-based observability tools.</p>
|
||
<p>The flags are exposed through <a class="reference internal" href="../library/sysconfig.html#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a>, so extension modules built by
|
||
tools that consume Python’s build configuration inherit frame pointers by
|
||
default. This propagation is intentional: mixed Python/native profiling needs
|
||
an unbroken frame-pointer chain through the interpreter, extension modules,
|
||
embedding applications, and native libraries.</p>
|
||
<div class="admonition important">
|
||
<p class="admonition-title">Important</p>
|
||
<p>Third-party build backends and native build systems should preserve these
|
||
flags when they consume Python’s <a class="reference internal" href="../library/sysconfig.html#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> values. Build systems
|
||
that compile C, C++, Rust, or other native code without inheriting Python’s
|
||
compiler flags should enable equivalent frame-pointer flags themselves. A
|
||
single native component built without frame pointers can break stack
|
||
unwinding for the whole Python process.</p>
|
||
</div>
|
||
<p>(Contributed by Pablo Galindo Salgado and Savannah Ostrowski in
|
||
<a class="reference external" href="https://github.com/python/cpython/issues/149201">gh-149201</a>; PEP 831 written by Pablo Galindo Salgado, Ken Jin,
|
||
Savannah Ostrowski, and Diego Russo.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-28"></span><a class="pep reference external" href="https://peps.python.org/pep-0831/"><strong>PEP 831</strong></a> for further details.</p>
|
||
</div>
|
||
</section>
|
||
<section id="pep-798-unpacking-in-comprehensions">
|
||
<span id="whatsnew315-unpacking-in-comprehensions"></span><h3><span class="target" id="index-29"></span><a class="pep reference external" href="https://peps.python.org/pep-0798/"><strong>PEP 798</strong></a>: Unpacking in comprehensions<a class="headerlink" href="#pep-798-unpacking-in-comprehensions" title="Link to this heading">¶</a></h3>
|
||
<p>List, set, and dictionary comprehensions, as well as generator expressions, now
|
||
support unpacking with <code class="docutils literal notranslate"><span class="pre">*</span></code> and <code class="docutils literal notranslate"><span class="pre">**</span></code>. This extends the unpacking syntax
|
||
from <span class="target" id="index-30"></span><a class="pep reference external" href="https://peps.python.org/pep-0448/"><strong>PEP 448</strong></a> to comprehensions, providing a new syntax for combining an
|
||
arbitrary number of iterables or dictionaries into a single flat structure.
|
||
This new syntax is a direct alternative to nested comprehensions,
|
||
<a class="reference internal" href="../library/itertools.html#itertools.chain" title="itertools.chain"><code class="xref py py-func docutils literal notranslate"><span class="pre">itertools.chain()</span></code></a>, and <a class="reference internal" href="../library/itertools.html#itertools.chain.from_iterable" title="itertools.chain.from_iterable"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itertools.chain.from_iterable()</span></code></a>. For
|
||
example:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">lists</span> <span class="o">=</span> <span class="p">[[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="p">[</span><span class="mi">5</span><span class="p">]]</span>
|
||
<span class="gp">>>> </span><span class="p">[</span><span class="o">*</span><span class="n">L</span> <span class="k">for</span> <span class="n">L</span> <span class="ow">in</span> <span class="n">lists</span><span class="p">]</span> <span class="c1"># equivalent to [x for L in lists for x in L]</span>
|
||
<span class="go">[1, 2, 3, 4, 5]</span>
|
||
|
||
<span class="gp">>>> </span><span class="n">sets</span> <span class="o">=</span> <span class="p">[{</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">},</span> <span class="p">{</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">},</span> <span class="p">{</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">}]</span>
|
||
<span class="gp">>>> </span><span class="p">{</span><span class="o">*</span><span class="n">s</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">sets</span><span class="p">}</span> <span class="c1"># equivalent to {x for s in sets for x in s}</span>
|
||
<span class="go">{1, 2, 3, 4}</span>
|
||
|
||
<span class="gp">>>> </span><span class="n">dicts</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'a'</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span> <span class="p">{</span><span class="s1">'b'</span><span class="p">:</span> <span class="mi">2</span><span class="p">},</span> <span class="p">{</span><span class="s1">'a'</span><span class="p">:</span> <span class="mi">3</span><span class="p">}]</span>
|
||
<span class="gp">>>> </span><span class="p">{</span><span class="o">**</span><span class="n">d</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">dicts</span><span class="p">}</span> <span class="c1"># equivalent to {k: v for d in dicts for k,v in d.items()}</span>
|
||
<span class="go">{'a': 3, 'b': 2}</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Generator expressions can similarly use unpacking to yield values from multiple
|
||
iterables:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">gen</span> <span class="o">=</span> <span class="p">(</span><span class="o">*</span><span class="n">L</span> <span class="k">for</span> <span class="n">L</span> <span class="ow">in</span> <span class="n">lists</span><span class="p">)</span> <span class="c1"># equivalent to (x for L in lists for x in L)</span>
|
||
<span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">gen</span><span class="p">)</span>
|
||
<span class="go">[1, 2, 3, 4, 5]</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>This change also extends to asynchronous generator expressions, such that, for
|
||
example, <code class="docutils literal notranslate"><span class="pre">(*a</span> <span class="pre">async</span> <span class="pre">for</span> <span class="pre">a</span> <span class="pre">in</span> <span class="pre">agen())</span></code> is equivalent to <code class="docutils literal notranslate"><span class="pre">(x</span> <span class="pre">async</span> <span class="pre">for</span> <span class="pre">a</span> <span class="pre">in</span>
|
||
<span class="pre">agen()</span> <span class="pre">for</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">a)</span></code>.</p>
|
||
<p>(Contributed by Adam Hartz in <a class="reference external" href="https://github.com/python/cpython/issues/143055">gh-143055</a>.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-31"></span><a class="pep reference external" href="https://peps.python.org/pep-0798/"><strong>PEP 798</strong></a> for further details.</p>
|
||
</div>
|
||
</section>
|
||
<section id="pep-829-package-startup-configuration-files">
|
||
<span id="whatsnew315-startup-files"></span><h3><span class="target" id="index-32"></span><a class="pep reference external" href="https://peps.python.org/pep-0829/"><strong>PEP 829</strong></a>: Package startup configuration files<a class="headerlink" href="#pep-829-package-startup-configuration-files" title="Link to this heading">¶</a></h3>
|
||
<p>Loaded by the <a class="reference internal" href="../library/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> module when <code class="docutils literal notranslate"><span class="pre">-S</span></code> is not given, <a class="reference internal" href="../library/site.html#site-pth-files"><span class="std std-ref">.pth files</span></a>
|
||
can contain lines that both extend <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> and execute arbitrary code
|
||
when the line starts with <code class="docutils literal notranslate"><span class="pre">import</span></code> (followed by a space or tab). The latter
|
||
functionality can be problematic, since it is difficult to know exactly what
|
||
gets executed when Python starts up.</p>
|
||
<p>As a step towards improving the ability to audit pre-start executable code,
|
||
Python 3.15 introduces <a class="reference internal" href="../library/site.html#site-start-files"><span class="std std-ref">.start files</span></a> which contain entry point
|
||
specifications of the form <code class="docutils literal notranslate"><span class="pre">pkg.mod:callable</span></code> where <code class="docutils literal notranslate"><span class="pre">pkg.mod</span></code> is the
|
||
import path to the given callable. When Python starts up, the callable is
|
||
located and called with no arguments.</p>
|
||
<p><code class="docutils literal notranslate"><span class="pre">import</span></code> lines in <code class="file docutils literal notranslate"><span class="pre">.pth</span></code> files are silently deprecated. When a
|
||
matching <code class="file docutils literal notranslate"><span class="pre">.start</span></code> file is found, <code class="docutils literal notranslate"><span class="pre">import</span></code> lines in <code class="file docutils literal notranslate"><span class="pre">.pth</span></code> files
|
||
are ignored. There is no change to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> extension lines in
|
||
<code class="file docutils literal notranslate"><span class="pre">.pth</span></code> files.</p>
|
||
<p>The <a class="reference internal" href="../library/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> module also provides <a class="reference internal" href="../library/site.html#site.StartupState" title="site.StartupState"><code class="xref py py-class docutils literal notranslate"><span class="pre">site.StartupState</span></code></a> to batch
|
||
startup processing for multiple site directories, ensuring all static path
|
||
extensions are applied before any startup code is executed. <a class="reference internal" href="../library/site.html#site.main" title="site.main"><code class="xref py py-func docutils literal notranslate"><span class="pre">site.main()</span></code></a>
|
||
uses an instance of this class implicitly to batch process all startup
|
||
configuration files during normal interpreter startup. Callers needing the
|
||
same batching behavior can build a <code class="xref py py-class docutils literal notranslate"><span class="pre">StartupState</span></code> directly and
|
||
drive it with <a class="reference internal" href="../library/site.html#site.StartupState.addsitedir" title="site.StartupState.addsitedir"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addsitedir()</span></code></a>,
|
||
<a class="reference internal" href="../library/site.html#site.StartupState.addusersitepackages" title="site.StartupState.addusersitepackages"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addusersitepackages()</span></code></a>, and
|
||
<a class="reference internal" href="../library/site.html#site.StartupState.addsitepackages" title="site.StartupState.addsitepackages"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addsitepackages()</span></code></a>, then call
|
||
<a class="reference internal" href="../library/site.html#site.StartupState.process" title="site.StartupState.process"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process()</span></code></a> once at the end of the batch.</p>
|
||
<p>(Contributed by Barry Warsaw in <a class="reference external" href="https://github.com/python/cpython/issues/148641">gh-148641</a> and <a class="reference external" href="https://github.com/python/cpython/issues/150228">gh-150228</a>.)</p>
|
||
</section>
|
||
<section id="pep-803-stable-abi-for-free-threaded-builds">
|
||
<span id="whatsnew315-abi3t"></span><h3><span class="target" id="index-33"></span><a class="pep reference external" href="https://peps.python.org/pep-0803/"><strong>PEP 803</strong></a>: Stable ABI for free-threaded builds<a class="headerlink" href="#pep-803-stable-abi-for-free-threaded-builds" title="Link to this heading">¶</a></h3>
|
||
<p>C extensions that target the <a class="reference internal" href="../c-api/stable.html#stable-abi"><span class="std std-ref">Stable ABI</span></a> can now be
|
||
compiled for the new <em>Stable ABI for Free-Threaded Builds</em> (also known
|
||
as <code class="docutils literal notranslate"><span class="pre">abi3t</span></code>), which makes them compatible with
|
||
<a class="reference internal" href="../glossary.html#term-free-threaded-build"><span class="xref std std-term">free-threaded builds</span></a> of CPython.
|
||
This usually requires some non-trivial changes to the source code;
|
||
specifically:</p>
|
||
<ul class="simple">
|
||
<li><p>Switching to API introduced in <span class="target" id="index-34"></span><a class="pep reference external" href="https://peps.python.org/pep-0697/"><strong>PEP 697</strong></a> (Python 3.12), such as
|
||
negative <a class="reference internal" href="../c-api/type.html#c.PyType_Spec.basicsize" title="PyType_Spec.basicsize"><code class="xref c c-member docutils literal notranslate"><span class="pre">basicsize</span></code></a> and
|
||
<a class="reference internal" href="../c-api/object.html#c.PyObject_GetTypeData" title="PyObject_GetTypeData"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_GetTypeData()</span></code></a>, rather than making <a class="reference internal" href="../c-api/structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a>
|
||
part of the instance struct; and</p></li>
|
||
<li><p>Switching from a <code class="docutils literal notranslate"><span class="pre">PyInit_</span></code> function to a new export hook,
|
||
<a class="reference internal" href="../c-api/extension-modules.html#c.PyModExport_modulename" title="PyModExport_modulename"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModExport_*</span></code></a>, introduced for this
|
||
purpose in <span class="target" id="index-35"></span><a class="pep reference external" href="https://peps.python.org/pep-0793/"><strong>PEP 793</strong></a>, with a new <a class="reference internal" href="../c-api/slots.html#c.PySlot" title="PySlot"><code class="xref c c-type docutils literal notranslate"><span class="pre">PySlot</span></code></a> structure
|
||
introduced in <span class="target" id="index-36"></span><a class="pep reference external" href="https://peps.python.org/pep-0820/"><strong>PEP 820</strong></a>.</p></li>
|
||
</ul>
|
||
<p>Note that Stable ABI does not offer all the functionality that CPython
|
||
has to offer.
|
||
Extensions that cannot switch to <code class="docutils literal notranslate"><span class="pre">abi3t</span></code> should continue to build for
|
||
the existing Stable ABI (<code class="docutils literal notranslate"><span class="pre">abi3</span></code>) and the version-specific ABI for
|
||
free-threading (<code class="docutils literal notranslate"><span class="pre">cp315t</span></code>) separately.</p>
|
||
<p>Stable ABI for Free-Threaded Builds should typically
|
||
be selected in a build tool. Tools with <code class="docutils literal notranslate"><span class="pre">abi3t</span></code> support include
|
||
meson-python, scikit-build-core, and Maturin; see
|
||
<a class="reference internal" href="../howto/abi3t-migration.html#abi3t-migration-build"><span class="std std-ref">Setting up the build</span></a> for links to their documentation on <code class="docutils literal notranslate"><span class="pre">abi3t</span></code> builds.
|
||
If your build tool does not support <code class="docutils literal notranslate"><span class="pre">abi3t</span></code>, compile for <code class="docutils literal notranslate"><span class="pre">cp315t</span></code> separately.
|
||
If not using a build tool – or when writing such a tool – you can select
|
||
<code class="docutils literal notranslate"><span class="pre">abi3t</span></code> by setting the macro <code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_TARGET_ABI3T</span></code> as discussed
|
||
in <a class="reference internal" href="../c-api/stable.html#abi3-compiling"><span class="std std-ref">Compiling for Stable ABI</span></a>.</p>
|
||
<p>A practical <a class="reference internal" href="../howto/abi3t-migration.html#abi3t-migration-howto"><span class="std std-ref">migration guide</span></a> for switching to
|
||
<code class="docutils literal notranslate"><span class="pre">abi3t</span></code> is available.
|
||
The community-maintained <a class="reference external" href="https://py-free-threading.github.io/abi3t/">Python Free-Threading Guide</a> provides examples of building
|
||
and testing <code class="docutils literal notranslate"><span class="pre">abi3t</span></code> wheels.</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-37"></span><a class="pep reference external" href="https://peps.python.org/pep-0803/"><strong>PEP 803</strong></a> for further details.</p>
|
||
</div>
|
||
</section>
|
||
<section id="pep-788-protecting-the-c-api-from-interpreter-finalization">
|
||
<span id="whatsnew315-c-api-interpreter-finalization"></span><h3><span class="target" id="index-38"></span><a class="pep reference external" href="https://peps.python.org/pep-0788/"><strong>PEP 788</strong></a>: Protecting the C API from interpreter finalization<a class="headerlink" href="#pep-788-protecting-the-c-api-from-interpreter-finalization" title="Link to this heading">¶</a></h3>
|
||
<p>In the C API, <a class="reference internal" href="../glossary.html#term-interpreter-shutdown"><span class="xref std std-term">interpreter finalization</span></a> can be
|
||
problematic for many extensions, because <a class="reference internal" href="../glossary.html#term-attached-thread-state"><span class="xref std std-term">attaching</span></a> a thread state will permanently hang the thread, resulting in deadlocks
|
||
and other spurious issues. Additionally, it has historically been impossible
|
||
to safely check whether an interpreter is alive before using it, leading to crashes
|
||
when a thread concurrently deletes an interpreter while another thread is
|
||
trying to attach to it.</p>
|
||
<p>There are now several new suites of APIs to circumvent these problems:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../c-api/interp-lifecycle.html#interpreter-guards"><span class="std std-ref">Interpreter guards</span></a>, which prevent an interpreter
|
||
from finalizing.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/interp-lifecycle.html#interpreter-views"><span class="std std-ref">Interpreter views</span></a>, which allow thread-safe access
|
||
to an interpreter that may be concurrently finalizing or deleted.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/threads.html#c-api-attach-detach"><span class="std std-ref">New APIs</span></a> to automatically attach and detach
|
||
thread states that come with built-in protection against finalization.</p></li>
|
||
</ul>
|
||
<p>In addition, APIs in the <code class="docutils literal notranslate"><span class="pre">PyGILState</span></code> family (most notably
|
||
<a class="reference internal" href="../c-api/threads.html#c.PyGILState_Ensure" title="PyGILState_Ensure"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyGILState_Ensure()</span></code></a> and <a class="reference internal" href="../c-api/threads.html#c.PyGILState_Release" title="PyGILState_Release"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyGILState_Release()</span></code></a>) have been
|
||
<a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>. There is <strong>no</strong> plan to remove them, and existing
|
||
code will continue to work, but there will be no new <code class="docutils literal notranslate"><span class="pre">PyGILState</span></code> APIs
|
||
in future versions of Python.</p>
|
||
<p>(Contributed by Peter Bierma in <a class="reference external" href="https://github.com/python/cpython/issues/149101">gh-149101</a>.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-39"></span><a class="pep reference external" href="https://peps.python.org/pep-0788/"><strong>PEP 788</strong></a> for further details.</p>
|
||
</div>
|
||
</section>
|
||
<section id="improved-error-messages">
|
||
<span id="whatsnew315-improved-error-messages"></span><h3>Improved error messages<a class="headerlink" href="#improved-error-messages" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>The interpreter now provides more helpful suggestions in <a class="reference internal" href="../builtins/exceptions.html#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a>
|
||
exceptions when accessing an attribute on an object that does not exist, but
|
||
a similar attribute is available through one of its members.</p>
|
||
<p>For example, if the object has an attribute that itself exposes the requested
|
||
name, the error message will suggest accessing it via that inner attribute:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">dataclasses</span><span class="w"> </span><span class="kn">import</span> <span class="n">dataclass</span>
|
||
<span class="kn">from</span><span class="w"> </span><span class="nn">math</span><span class="w"> </span><span class="kn">import</span> <span class="n">pi</span>
|
||
|
||
<span class="nd">@dataclass</span>
|
||
<span class="k">class</span><span class="w"> </span><span class="nc">Circle</span><span class="p">:</span>
|
||
<span class="n">radius</span><span class="p">:</span> <span class="nb">float</span>
|
||
|
||
<span class="nd">@property</span>
|
||
<span class="k">def</span><span class="w"> </span><span class="nf">area</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">float</span><span class="p">:</span>
|
||
<span class="k">return</span> <span class="n">pi</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">radius</span><span class="o">**</span><span class="mi">2</span>
|
||
|
||
<span class="k">class</span><span class="w"> </span><span class="nc">Container</span><span class="p">:</span>
|
||
<span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inner</span><span class="p">:</span> <span class="n">Circle</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
|
||
<span class="bp">self</span><span class="o">.</span><span class="n">inner</span> <span class="o">=</span> <span class="n">inner</span>
|
||
|
||
<span class="n">circle</span> <span class="o">=</span> <span class="n">Circle</span><span class="p">(</span><span class="n">radius</span><span class="o">=</span><span class="mf">4.0</span><span class="p">)</span>
|
||
<span class="n">container</span> <span class="o">=</span> <span class="n">Container</span><span class="p">(</span><span class="n">circle</span><span class="p">)</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="n">container</span><span class="o">.</span><span class="n">area</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Running this code now produces a clearer suggestion:</p>
|
||
<div class="highlight-pytb notranslate"><div class="highlight"><pre><span></span><span class="gt">Traceback (most recent call last):</span>
|
||
File <span class="nb">"example.py"</span>, line <span class="m">18</span>, in <span class="n"><module></span>
|
||
<span class="w"> </span><span class="nb">print</span><span class="p">(</span><span class="n">container</span><span class="o">.</span><span class="n">area</span><span class="p">)</span>
|
||
<span class="w"> </span><span class="pm">^^^^^^^^^^^^^^</span>
|
||
<span class="gr">AttributeError</span>: <span class="n">'Container' object has no attribute 'area'. Did you mean '.inner.area' instead of '.area'?</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>When an <a class="reference internal" href="../builtins/exceptions.html#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a> on a builtin type has no close match via
|
||
Levenshtein distance, the error message now checks a static table of common
|
||
method names from other languages (JavaScript, Java, Ruby, C#) and suggests
|
||
the Python equivalent:</p>
|
||
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
<span class="c">...</span>
|
||
<span class="gr">AttributeError</span>: <span class="n">'list' object has no attribute 'push'. Did you mean '.append'?</span>
|
||
|
||
<span class="gp">>>> </span><span class="s1">'hello'</span><span class="o">.</span><span class="n">toUpperCase</span><span class="p">()</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
<span class="c">...</span>
|
||
<span class="gr">AttributeError</span>: <span class="n">'str' object has no attribute 'toUpperCase'. Did you mean '.upper'?</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>When the Python equivalent is a language construct rather than a method,
|
||
the hint describes the construct directly:</p>
|
||
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{}</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s2">"a"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
<span class="c">...</span>
|
||
<span class="gr">AttributeError</span>: <span class="n">'dict' object has no attribute 'put'. Use d[k] = v.</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>When a mutable method is called on an immutable type, the hint suggests
|
||
the mutable counterpart:</p>
|
||
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
<span class="c">...</span>
|
||
<span class="gr">AttributeError</span>: <span class="n">'tuple' object has no attribute 'append'. Did you mean to use a 'list' object?</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>These hints also work for subclasses of builtin types.</p>
|
||
<p>(Contributed by Matt Van Horn in <a class="reference external" href="https://github.com/python/cpython/issues/146406">gh-146406</a>.)</p>
|
||
</li>
|
||
<li><p>The interpreter now tries to provide a suggestion when
|
||
<a class="reference internal" href="../builtins/functions.html#delattr" title="delattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">delattr()</span></code></a> fails due to a missing attribute.
|
||
When an attribute name that closely resembles an existing attribute is used,
|
||
the interpreter will suggest the correct attribute name in the error message.
|
||
For example:</p>
|
||
<div class="highlight-pycon notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">class</span><span class="w"> </span><span class="nc">A</span><span class="p">:</span>
|
||
<span class="gp">... </span> <span class="k">pass</span>
|
||
<span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">A</span><span class="p">()</span>
|
||
<span class="gp">>>> </span><span class="n">a</span><span class="o">.</span><span class="n">abcde</span> <span class="o">=</span> <span class="mi">1</span>
|
||
<span class="gp">>>> </span><span class="k">del</span> <span class="n">a</span><span class="o">.</span><span class="n">abcdf</span>
|
||
<span class="gt">Traceback (most recent call last):</span>
|
||
<span class="c">...</span>
|
||
<span class="gr">AttributeError</span>: <span class="n">'A' object has no attribute 'abcdf'. Did you mean: 'abcde'?</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Nikita Sobolev and Pranjal Prajapati in <a class="reference external" href="https://github.com/python/cpython/issues/136588">gh-136588</a>.)</p>
|
||
</li>
|
||
<li><p>Several error messages incorrectly using the term “argument” have been corrected.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/133382">gh-133382</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
<section id="other-language-changes">
|
||
<h2>Other language changes<a class="headerlink" href="#other-language-changes" title="Link to this heading">¶</a></h2>
|
||
<ul id="whatsnew315-utf8-default">
|
||
<li><p>Python now uses <a class="reference external" href="https://en.wikipedia.org/wiki/UTF-8">UTF-8</a> as the default encoding, independent of the system’s
|
||
environment. This means that I/O operations without an explicit encoding,
|
||
for example, <code class="docutils literal notranslate"><span class="pre">open('flying-circus.txt')</span></code>, will use UTF-8.
|
||
UTF-8 is a widely-supported <a class="reference external" href="https://home.unicode.org/">Unicode</a> character encoding that has become a
|
||
<em>de facto</em> standard for representing text, including nearly every webpage
|
||
on the internet, many common file formats, programming languages, and more.</p>
|
||
<p>This only applies when no <code class="docutils literal notranslate"><span class="pre">encoding</span></code> argument is given. For best
|
||
compatibility between versions of Python, ensure that an explicit <code class="docutils literal notranslate"><span class="pre">encoding</span></code>
|
||
argument is always provided. The <a class="reference internal" href="../library/io.html#io-encoding-warning"><span class="std std-ref">opt-in encoding warning</span></a>
|
||
can be used to identify code that may be affected by this change.
|
||
The special <code class="docutils literal notranslate"><span class="pre">encoding='locale'</span></code> argument uses the current locale
|
||
encoding, and has been supported since Python 3.10.</p>
|
||
<p>To retain the previous behaviour, Python’s UTF-8 mode may be disabled with
|
||
the <span class="target" id="index-40"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8=0</span></code></a> environment variable or 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> <span class="pre">utf8=0</span></code></a> command-line option.</p>
|
||
<p>(Contributed by Adam Turner in <a class="reference external" href="https://github.com/python/cpython/issues/133711">gh-133711</a>; PEP 686 written by Inada Naoki.)</p>
|
||
<div class="admonition seealso">
|
||
<p class="admonition-title">See also</p>
|
||
<p><span class="target" id="index-41"></span><a class="pep reference external" href="https://peps.python.org/pep-0686/"><strong>PEP 686</strong></a> for further details.</p>
|
||
</div>
|
||
</li>
|
||
<li id="whatsnew315-color-interpreter-help"><p>The interpreter help (such as <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">--help</span></code>) is now in color.
|
||
This can be controlled by <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/148766">gh-148766</a>.)</p>
|
||
</li>
|
||
<li id="whatsnew315-color-exceptions"><p>Unraisable exceptions are now highlighted with color by default. This can be
|
||
controlled by <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Peter Bierma in <a class="reference external" href="https://github.com/python/cpython/issues/134170">gh-134170</a>.)</p>
|
||
</li>
|
||
<li id="whatsnew315-more-color"><p>More color in
|
||
<a class="reference internal" href="#whatsnew315-color-argparse"><span class="std std-ref">argparse</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-ast"><span class="std std-ref">ast</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-calendar"><span class="std std-ref">calendar</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-difflib"><span class="std std-ref">difflib</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-http-server"><span class="std std-ref">http.server</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-pickletools"><span class="std std-ref">pickletools</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-pyrepl-completion"><span class="std std-ref">PyREPL tab completion</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-interpreter-help"><span class="std std-ref">python –help</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-sqlite3"><span class="std std-ref">sqlite3</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-timeit"><span class="std std-ref">timeit</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-tokenize"><span class="std std-ref">tokenize</span></a>,
|
||
<a class="reference internal" href="#whatsnew315-color-exceptions"><span class="std std-ref">unraisable exceptions</span></a> and
|
||
<a class="reference internal" href="../glossary.html#term-stdlib"><span class="xref std std-term">stdlib</span></a> (ast, compileall, doctest, gzip, inspect, json.tool, pdb,
|
||
profiling.sampling, random, regrtest, sqlite3, timeit, tokenize, trace,
|
||
unittest, uuid, zipapp, zipfile) CLI help.</p></li>
|
||
<li><p>The <a class="reference internal" href="../reference/datamodel.html#object.__repr__" title="object.__repr__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__repr__()</span></code></a> of <a class="reference internal" href="../builtins/exceptions.html#ImportError" title="ImportError"><code class="xref py py-class docutils literal notranslate"><span class="pre">ImportError</span></code></a> and <a class="reference internal" href="../builtins/exceptions.html#ModuleNotFoundError" title="ModuleNotFoundError"><code class="xref py py-class docutils literal notranslate"><span class="pre">ModuleNotFoundError</span></code></a>
|
||
now shows “name” and “path” as <code class="docutils literal notranslate"><span class="pre">name=<name></span></code> and <code class="docutils literal notranslate"><span class="pre">path=<path></span></code> if they were given
|
||
as keyword arguments at construction time.
|
||
(Contributed by Serhiy Storchaka, Oleg Iarygin, and Yoav Nir in <a class="reference external" href="https://github.com/python/cpython/issues/74185">gh-74185</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../reference/datamodel.html#object.__dict__" title="object.__dict__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__dict__</span></code></a> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">__weakref__</span></code> descriptors now use a
|
||
single descriptor instance per interpreter, shared across all types that
|
||
need them.
|
||
This speeds up class creation, and helps avoid reference cycles.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/135228">gh-135228</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../using/cmdline.html#cmdoption-W"><code class="xref std std-option docutils literal notranslate"><span class="pre">-W</span></code></a> option and the <span class="target" id="index-42"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONWARNINGS"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONWARNINGS</span></code></a> environment variable
|
||
can now specify regular expressions instead of literal strings to match
|
||
the warning message and the module name, if the corresponding field starts
|
||
and ends with a forward slash (<code class="docutils literal notranslate"><span class="pre">/</span></code>).
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/134716">gh-134716</a>.)</p></li>
|
||
<li><p>Functions that take timestamp or timeout arguments now accept any real
|
||
numbers (such as <a class="reference internal" href="../library/decimal.html#decimal.Decimal" title="decimal.Decimal"><code class="xref py py-class docutils literal notranslate"><span class="pre">Decimal</span></code></a> and <a class="reference internal" href="../library/fractions.html#fractions.Fraction" title="fractions.Fraction"><code class="xref py py-class docutils literal notranslate"><span class="pre">Fraction</span></code></a>),
|
||
not only integers or floats, although this does not improve precision.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/67795">gh-67795</a>.)</p></li>
|
||
</ul>
|
||
<ul id="whatsnew315-bytearray-take-bytes">
|
||
<li><p>Added <a class="reference internal" href="../builtins/stdtypes.html#bytearray.take_bytes" title="bytearray.take_bytes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytearray.take_bytes(n=None,</span> <span class="pre">/)</span></code></a> to take
|
||
bytes out of a <a class="reference internal" href="../builtins/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> without copying. This enables optimizing code
|
||
which must return <a class="reference internal" href="../builtins/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> after working with a mutable buffer of bytes
|
||
such as data buffering, network protocol parsing, encoding, decoding,
|
||
and compression. Common code patterns which can be optimized with
|
||
<a class="reference internal" href="../builtins/stdtypes.html#bytearray.take_bytes" title="bytearray.take_bytes"><code class="xref py py-func docutils literal notranslate"><span class="pre">take_bytes()</span></code></a> are listed below.</p>
|
||
<table class="docutils align-default" id="id12">
|
||
<caption><span class="caption-text">Suggested optimizing refactors</span><a class="headerlink" href="#id12" title="Link to this table">¶</a></caption>
|
||
<thead>
|
||
<tr class="row-odd"><th class="head"><p>Description</p></th>
|
||
<th class="head"><p>Old</p></th>
|
||
<th class="head"><p>New</p></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr class="row-even"><td><p>Return <a class="reference internal" href="../builtins/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> after working with <a class="reference internal" href="../builtins/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a></p></td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">read</span><span class="p">()</span> <span class="o">-></span> <span class="nb">bytes</span><span class="p">:</span>
|
||
<span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
|
||
<span class="o">...</span>
|
||
<span class="k">return</span> <span class="nb">bytes</span><span class="p">(</span><span class="n">buffer</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">read</span><span class="p">()</span> <span class="o">-></span> <span class="nb">bytes</span><span class="p">:</span>
|
||
<span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
|
||
<span class="o">...</span>
|
||
<span class="k">return</span> <span class="n">buffer</span><span class="o">.</span><span class="n">take_bytes</span><span class="p">()</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p>Empty a buffer getting the bytes</p></td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
|
||
<span class="o">...</span>
|
||
<span class="n">data</span> <span class="o">=</span> <span class="nb">bytes</span><span class="p">(</span><span class="n">buffer</span><span class="p">)</span>
|
||
<span class="n">buffer</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
|
||
<span class="o">...</span>
|
||
<span class="n">data</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">take_bytes</span><span class="p">()</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr class="row-even"><td><p>Split a buffer at a specific separator</p></td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc</span><span class="se">\n</span><span class="s1">def'</span><span class="p">)</span>
|
||
<span class="n">n</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="sa">b</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span>
|
||
<span class="n">data</span> <span class="o">=</span> <span class="nb">bytes</span><span class="p">(</span><span class="n">buffer</span><span class="p">[:</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
|
||
<span class="k">del</span> <span class="n">buffer</span><span class="p">[:</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
|
||
<span class="k">assert</span> <span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">'abc</span><span class="se">\n</span><span class="s1">'</span>
|
||
<span class="k">assert</span> <span class="n">buffer</span> <span class="o">==</span> <span class="nb">bytearray</span><span class="p">(</span><span class="sa">b</span><span class="s1">'def'</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc</span><span class="se">\n</span><span class="s1">def'</span><span class="p">)</span>
|
||
<span class="n">n</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="sa">b</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span>
|
||
<span class="n">data</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">take_bytes</span><span class="p">(</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr class="row-odd"><td><p>Split a buffer at a specific separator; discard after the separator</p></td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc</span><span class="se">\n</span><span class="s1">def'</span><span class="p">)</span>
|
||
<span class="n">n</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="sa">b</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span>
|
||
<span class="n">data</span> <span class="o">=</span> <span class="nb">bytes</span><span class="p">(</span><span class="n">buffer</span><span class="p">[:</span><span class="n">n</span><span class="p">])</span>
|
||
<span class="n">buffer</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>
|
||
<span class="k">assert</span> <span class="n">data</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">'abc'</span>
|
||
<span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">buffer</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
<td><div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">buffer</span> <span class="o">=</span> <span class="nb">bytearray</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc</span><span class="se">\n</span><span class="s1">def'</span><span class="p">)</span>
|
||
<span class="n">n</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="sa">b</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="p">)</span>
|
||
<span class="n">buffer</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
|
||
<span class="n">data</span> <span class="o">=</span> <span class="n">buffer</span><span class="o">.</span><span class="n">take_bytes</span><span class="p">()</span>
|
||
</pre></div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p>(Contributed by Cody Maloney in <a class="reference external" href="https://github.com/python/cpython/issues/139871">gh-139871</a>.)</p>
|
||
</li>
|
||
<li><p>Many functions related to compiling or parsing Python code, such as
|
||
<a class="reference internal" href="../builtins/functions.html#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a>, <a class="reference internal" href="../library/ast.html#ast.parse" title="ast.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">ast.parse()</span></code></a>, <a class="reference internal" href="../library/symtable.html#symtable.symtable" title="symtable.symtable"><code class="xref py py-func docutils literal notranslate"><span class="pre">symtable.symtable()</span></code></a>,
|
||
and <a class="reference internal" href="../library/importlib.html#importlib.abc.InspectLoader.source_to_code" title="importlib.abc.InspectLoader.source_to_code"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.abc.InspectLoader.source_to_code()</span></code></a>, now allow the module
|
||
name to be passed. It is needed to unambiguously <a class="reference internal" href="../library/warnings.html#warning-filter"><span class="std std-ref">filter</span></a>
|
||
syntax warnings by module name.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/135801">gh-135801</a>.)</p></li>
|
||
<li><p>Allowed defining the <em>__dict__</em> and <em>__weakref__</em> <a class="reference internal" href="../reference/datamodel.html#slots"><span class="std std-ref">__slots__</span></a>
|
||
for any class.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/41779">gh-41779</a>.)</p></li>
|
||
<li><p>Allowed defining any <a class="reference internal" href="../reference/datamodel.html#slots"><span class="std std-ref">__slots__</span></a> for a class derived from
|
||
<a class="reference internal" href="../builtins/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a> (including classes created by <a class="reference internal" href="../library/collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">collections.namedtuple()</span></code></a>).
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/41779">gh-41779</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../builtins/functions.html#slice" title="slice"><code class="xref py py-class docutils literal notranslate"><span class="pre">slice</span></code></a> type now supports subscription,
|
||
making it a <a class="reference internal" href="../glossary.html#term-generic-type"><span class="xref std std-term">generic type</span></a>.
|
||
(Contributed by James Hilton-Balfe in <a class="reference external" href="https://github.com/python/cpython/issues/128335">gh-128335</a>.)</p></li>
|
||
<li><p>The class <a class="reference internal" href="../builtins/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a> now supports the <span class="c-expr sig sig-inline c"><span class="kt">float</span><span class="w"> </span><span class="kt">complex</span></span> and
|
||
<span class="c-expr sig sig-inline c"><span class="kt">double</span><span class="w"> </span><span class="kt">complex</span></span> C types: formatting characters <code class="docutils literal notranslate"><span class="pre">'Zf'</span></code> and <code class="docutils literal notranslate"><span class="pre">'Zd'</span></code>
|
||
respectively.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/146151">gh-146151</a> and <a class="reference external" href="https://github.com/python/cpython/issues/148675">gh-148675</a>.)</p></li>
|
||
<li><p>Allow the <em>count</em> argument of <a class="reference internal" href="../builtins/stdtypes.html#bytes.replace" title="bytes.replace"><code class="xref py py-meth docutils literal notranslate"><span class="pre">bytes.replace()</span></code></a> to be a keyword.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/147856">gh-147856</a>.)</p></li>
|
||
<li><p>Unary plus is now accepted in <a class="reference internal" href="../reference/compound_stmts.html#match"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">match</span></code></a> literal patterns, mirroring
|
||
the existing support for unary minus.
|
||
(Contributed by Bartosz Sławecki in <a class="reference external" href="https://github.com/python/cpython/issues/145239">gh-145239</a>.)</p></li>
|
||
<li><p>The import system now acquires per-module locks in hierarchical order
|
||
(parent packages before their submodules). This fixes a long-standing
|
||
deadlock where one thread importing <code class="docutils literal notranslate"><span class="pre">pkg.sub</span></code> and another importing
|
||
<code class="docutils literal notranslate"><span class="pre">pkg.sub.mod</span></code> could each block the other when <code class="docutils literal notranslate"><span class="pre">pkg/sub/__init__.py</span></code>
|
||
imports <code class="docutils literal notranslate"><span class="pre">pkg.sub.mod</span></code>.
|
||
(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/83065">gh-83065</a>.)</p></li>
|
||
<li><p>File names of Stable ABI extensions that use the <code class="docutils literal notranslate"><span class="pre">.so</span></code> suffix may now
|
||
include a multiarch tuple, for example, <code class="docutils literal notranslate"><span class="pre">foo.abi3-x86-64-linux-gnu.so</span></code>.
|
||
This permits stable ABI extensions for multiple architectures to be
|
||
co-installed into the same directory, without clashing with each
|
||
other, as regular dynamic extensions do.
|
||
(Contributed by Stefano Rivera in <a class="reference external" href="https://github.com/python/cpython/issues/122931">gh-122931</a>.)</p></li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">__cached__</span></code> attribute on modules, which was deprecated since version
|
||
3.13, is no longer set or taken into consideration by the import system or
|
||
standard library.
|
||
Use <a class="reference internal" href="../library/importlib.html#importlib.machinery.ModuleSpec.cached" title="importlib.machinery.ModuleSpec.cached"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__spec__.cached</span></code></a> instead.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://github.com/python/cpython/issues/97879">gh-97879</a>.)</p>
|
||
<p>Note that the <a class="reference internal" href="../reference/datamodel.html#module.__loader__" title="module.__loader__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__loader__</span></code></a> and <a class="reference internal" href="../reference/datamodel.html#module.__package__" title="module.__package__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__package__</span></code></a>
|
||
attributes are also deprecated and scheduled for removal.</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="default-interactive-shell">
|
||
<h2>Default interactive shell<a class="headerlink" href="#default-interactive-shell" title="Link to this heading">¶</a></h2>
|
||
<ul class="simple" id="whatsnew315-pyrepl-completion">
|
||
<li><p>Tab completions are now colored by object kind, based on
|
||
<a class="extlink-pypi reference external" href="https://pypi.org/project/fancycompleter/">fancycompleter</a>.
|
||
Set <span class="target" id="index-43"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHON_BASIC_COMPLETER"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_BASIC_COMPLETER</span></code></a> to fall back to <a class="reference internal" href="../library/rlcompleter.html#module-rlcompleter" title="rlcompleter: Python identifier completion, suitable for the GNU readline library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">rlcompleter</span></code></a>.
|
||
Color can also be controlled by <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Antonio Cuni and Pablo Galindo in <a class="reference external" href="https://github.com/python/cpython/issues/130472">gh-130472</a>.)</p></li>
|
||
<li><p>Tab completion now suggests module attributes in <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">...</span> <span class="pre">import</span></code> statements.
|
||
Attributes can only be suggested once the module is imported, so
|
||
<a class="reference internal" href="../glossary.html#term-stdlib"><span class="xref std std-term">stdlib</span></a> modules are imported automatically, while for
|
||
other modules the completer offers to import them when <kbd class="kbd docutils literal notranslate">Tab</kbd>
|
||
is pressed a second time.
|
||
(Contributed by Loïc Simon and Pablo Galindo in <a class="reference external" href="https://github.com/python/cpython/issues/140870">gh-140870</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="new-modules">
|
||
<h2>New modules<a class="headerlink" href="#new-modules" title="Link to this heading">¶</a></h2>
|
||
<section id="math-integer">
|
||
<h3>math.integer<a class="headerlink" href="#math-integer" title="Link to this heading">¶</a></h3>
|
||
<p>This module provides access to the mathematical functions for integer
|
||
arguments (<span class="target" id="index-44"></span><a class="pep reference external" href="https://peps.python.org/pep-0791/"><strong>PEP 791</strong></a>).
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/81313">gh-81313</a>.)</p>
|
||
</section>
|
||
</section>
|
||
<section id="improved-modules">
|
||
<h2>Improved modules<a class="headerlink" href="#improved-modules" title="Link to this heading">¶</a></h2>
|
||
<section id="argparse">
|
||
<h3>argparse<a class="headerlink" href="#argparse" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/argparse.html#argparse.BooleanOptionalAction" title="argparse.BooleanOptionalAction"><code class="xref py py-class docutils literal notranslate"><span class="pre">BooleanOptionalAction</span></code></a> action now supports single-dash
|
||
long options and alternate prefix characters.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/138525">gh-138525</a>.)</p></li>
|
||
<li><p>Changed the <em>suggest_on_error</em> parameter of <a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser" title="argparse.ArgumentParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">argparse.ArgumentParser</span></code></a> to
|
||
default to <code class="docutils literal notranslate"><span class="pre">True</span></code>. This enables suggestions for mistyped arguments by default.
|
||
(Contributed by Jakob Schluse in <a class="reference external" href="https://github.com/python/cpython/issues/140450">gh-140450</a>.)</p>
|
||
</li>
|
||
<li id="whatsnew315-color-argparse"><p>Added backtick markup support in <a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser" title="argparse.ArgumentParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">ArgumentParser</span></code></a> description
|
||
and epilog text to highlight inline code when color output is enabled.
|
||
(Contributed by Savannah Ostrowski in <a class="reference external" href="https://github.com/python/cpython/issues/142390">gh-142390</a>.)</p></li>
|
||
<li><p>Extended backtick markup to argument <code class="docutils literal notranslate"><span class="pre">help</span></code> text and added support for
|
||
double backticks (RST inline-literal style).
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/149375">gh-149375</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="array">
|
||
<h3>array<a class="headerlink" href="#array" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Support the <span class="c-expr sig sig-inline c"><span class="kt">float</span><span class="w"> </span><span class="kt">complex</span></span> and <span class="c-expr sig sig-inline c"><span class="kt">double</span><span class="w"> </span><span class="kt">complex</span></span> C types:
|
||
formatting characters <code class="docutils literal notranslate"><span class="pre">'Zf'</span></code> and <code class="docutils literal notranslate"><span class="pre">'Zd'</span></code> respectively.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/146151">gh-146151</a> and <a class="reference external" href="https://github.com/python/cpython/issues/148675">gh-148675</a>.)</p></li>
|
||
<li><p>Support half-floats (16-bit IEEE 754 binary interchange format): formatting
|
||
character <code class="docutils literal notranslate"><span class="pre">'e'</span></code>.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/146238">gh-146238</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/array.html#array.typecodes" title="array.typecodes"><code class="xref py py-data docutils literal notranslate"><span class="pre">array.typecodes</span></code></a> type changed from <a class="reference internal" href="../builtins/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> to <a class="reference internal" href="../builtins/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>
|
||
to support type codes longer than 1 character (<code class="docutils literal notranslate"><span class="pre">Zf</span></code> and <code class="docutils literal notranslate"><span class="pre">Zd</span></code>).
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/148675">gh-148675</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="ast">
|
||
<h3>ast<a class="headerlink" href="#ast" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-ast">
|
||
<li><p>Add <em>color</em> parameter to <a class="reference internal" href="../library/ast.html#ast.dump" title="ast.dump"><code class="xref py py-func docutils literal notranslate"><span class="pre">dump()</span></code></a>.
|
||
If <code class="docutils literal notranslate"><span class="pre">True</span></code>, the returned string is syntax highlighted using ANSI escape
|
||
sequences.
|
||
If <code class="docutils literal notranslate"><span class="pre">False</span></code> (the default), colored output is always disabled.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/148981">gh-148981</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/ast.html#ast-cli"><span class="std std-ref">command-line</span></a> output is now syntax highlighted by default.
|
||
This can be <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">controlled using environment variables</span></a>.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/148981">gh-148981</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="asyncio">
|
||
<h3>asyncio<a class="headerlink" href="#asyncio" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added <a class="reference internal" href="../library/asyncio-task.html#asyncio.TaskGroup.cancel" title="asyncio.TaskGroup.cancel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TaskGroup.cancel</span></code></a> to allow early
|
||
termination of a task group, for instance, when the goal of the tasks has
|
||
been achieved or their services are no longer needed.
|
||
Previously this would involve unintuitive boilerplate such as an extra task
|
||
raising a custom exception which is then suppressed as it exits the task group.
|
||
(Contributed by John Belmonte in <a class="reference external" href="https://github.com/python/cpython/issues/127214">gh-127214</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="base64">
|
||
<h3>base64<a class="headerlink" href="#base64" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added the <em>pad</em> parameter in <a class="reference internal" href="../library/base64.html#base64.z85encode" title="base64.z85encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">z85encode()</span></code></a>.
|
||
(Contributed by Hauke Dämpfling in <a class="reference external" href="https://github.com/python/cpython/issues/143103">gh-143103</a>.)</p></li>
|
||
<li><p>Added the <em>padded</em> parameter in
|
||
<a class="reference internal" href="../library/base64.html#base64.b32encode" title="base64.b32encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32encode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b32decode" title="base64.b32decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32decode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b32hexencode" title="base64.b32hexencode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32hexencode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b32hexdecode" title="base64.b32hexdecode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32hexdecode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b64encode" title="base64.b64encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b64encode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b64decode" title="base64.b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b64decode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.urlsafe_b64encode" title="base64.urlsafe_b64encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlsafe_b64encode()</span></code></a>, and <a class="reference internal" href="../library/base64.html#base64.urlsafe_b64decode" title="base64.urlsafe_b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlsafe_b64decode()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/73613">gh-73613</a>.)</p></li>
|
||
<li><p>Added the <em>wrapcol</em> parameter in <a class="reference internal" href="../library/base64.html#base64.b16encode" title="base64.b16encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b16encode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b32encode" title="base64.b32encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32encode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b32hexencode" title="base64.b32hexencode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32hexencode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b64encode" title="base64.b64encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b64encode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b85encode" title="base64.b85encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b85encode()</span></code></a>, and
|
||
<a class="reference internal" href="../library/base64.html#base64.z85encode" title="base64.z85encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">z85encode()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143214">gh-143214</a> and <a class="reference external" href="https://github.com/python/cpython/issues/146431">gh-146431</a>.)</p></li>
|
||
<li><p>Added the <em>ignorechars</em> parameter in <a class="reference internal" href="../library/base64.html#base64.b16decode" title="base64.b16decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b16decode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b32decode" title="base64.b32decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32decode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b32hexdecode" title="base64.b32hexdecode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32hexdecode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b64decode" title="base64.b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b64decode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b85decode" title="base64.b85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b85decode()</span></code></a>, and
|
||
<a class="reference internal" href="../library/base64.html#base64.z85decode" title="base64.z85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">z85decode()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/144001">gh-144001</a> and <a class="reference external" href="https://github.com/python/cpython/issues/146431">gh-146431</a>.)</p></li>
|
||
<li><p>Added the <em>canonical</em> parameter in
|
||
<a class="reference internal" href="../library/base64.html#base64.b32decode" title="base64.b32decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32decode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b32hexdecode" title="base64.b32hexdecode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32hexdecode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.b64decode" title="base64.b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b64decode()</span></code></a>,
|
||
<a class="reference internal" href="../library/base64.html#base64.a85decode" title="base64.a85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">a85decode()</span></code></a>, <a class="reference internal" href="../library/base64.html#base64.b85decode" title="base64.b85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b85decode()</span></code></a>, and
|
||
<a class="reference internal" href="../library/base64.html#base64.z85decode" title="base64.z85decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">z85decode()</span></code></a>,
|
||
to reject encodings with non-zero padding bits or other non-canonical
|
||
forms.
|
||
(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/146311">gh-146311</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="binascii">
|
||
<h3>binascii<a class="headerlink" href="#binascii" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>Added functions for Base32 encoding:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/binascii.html#binascii.b2a_base32" title="binascii.b2a_base32"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base32()</span></code></a> and <a class="reference internal" href="../library/binascii.html#binascii.a2b_base32" title="binascii.a2b_base32"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base32()</span></code></a></p></li>
|
||
</ul>
|
||
<p>(Contributed by James Seo in <a class="reference external" href="https://github.com/python/cpython/issues/146192">gh-146192</a>.)</p>
|
||
</li>
|
||
<li><p>Added functions for Ascii85, Base85, and Z85 encoding:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/binascii.html#binascii.b2a_ascii85" title="binascii.b2a_ascii85"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_ascii85()</span></code></a> and <a class="reference internal" href="../library/binascii.html#binascii.a2b_ascii85" title="binascii.a2b_ascii85"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_ascii85()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/binascii.html#binascii.b2a_base85" title="binascii.b2a_base85"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base85()</span></code></a> and <a class="reference internal" href="../library/binascii.html#binascii.a2b_base85" title="binascii.a2b_base85"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base85()</span></code></a></p></li>
|
||
</ul>
|
||
<p>(Contributed by James Seo and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/101178">gh-101178</a>.)</p>
|
||
</li>
|
||
<li><p>Added the <em>padded</em> parameter in
|
||
<a class="reference internal" href="../library/binascii.html#binascii.b2a_base32" title="binascii.b2a_base32"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base32()</span></code></a>, <a class="reference internal" href="../library/binascii.html#binascii.a2b_base32" title="binascii.a2b_base32"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base32()</span></code></a>,
|
||
<a class="reference internal" href="../library/binascii.html#binascii.b2a_base64" title="binascii.b2a_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base64()</span></code></a>, and <a class="reference internal" href="../library/binascii.html#binascii.a2b_base64" title="binascii.a2b_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base64()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/73613">gh-73613</a>.)</p></li>
|
||
<li><p>Added the <em>wrapcol</em> parameter in <a class="reference internal" href="../library/binascii.html#binascii.b2a_base64" title="binascii.b2a_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base64()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143214">gh-143214</a>.)</p></li>
|
||
<li><p>Added the <em>alphabet</em> parameter in <a class="reference internal" href="../library/binascii.html#binascii.b2a_base64" title="binascii.b2a_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">b2a_base64()</span></code></a> and
|
||
<a class="reference internal" href="../library/binascii.html#binascii.a2b_base64" title="binascii.a2b_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base64()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/145980">gh-145980</a>.)</p></li>
|
||
<li><p>Added the <em>ignorechars</em> parameter in <a class="reference internal" href="../library/binascii.html#binascii.a2b_hex" title="binascii.a2b_hex"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_hex()</span></code></a>,
|
||
<a class="reference internal" href="../library/binascii.html#binascii.unhexlify" title="binascii.unhexlify"><code class="xref py py-func docutils literal notranslate"><span class="pre">unhexlify()</span></code></a>, and <a class="reference internal" href="../library/binascii.html#binascii.a2b_base64" title="binascii.a2b_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base64()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/144001">gh-144001</a> and <a class="reference external" href="https://github.com/python/cpython/issues/146431">gh-146431</a>.)</p></li>
|
||
<li><p>Added the <em>canonical</em> parameter in <a class="reference internal" href="../library/binascii.html#binascii.a2b_base64" title="binascii.a2b_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">a2b_base64()</span></code></a>,
|
||
to reject encodings with non-zero padding bits.
|
||
(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/146311">gh-146311</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="calendar">
|
||
<h3>calendar<a class="headerlink" href="#calendar" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-calendar">
|
||
<li><p><a class="reference internal" href="../library/calendar.html#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a>’s <a class="reference internal" href="../library/calendar.html#calendar-cli"><span class="std std-ref">command-line</span></a> text output has more
|
||
color. This can be controlled with <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/148352">gh-148352</a>.)</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/calendar.html#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a>’s <a class="reference internal" href="../library/calendar.html#calendar-cli"><span class="std std-ref">command-line</span></a> HTML output now
|
||
accepts the year-month option: <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">calendar</span> <span class="pre">-t</span> <span class="pre">html</span> <span class="pre">2009</span> <span class="pre">06</span></code>.
|
||
(Contributed by Pål Grønås Drange in <a class="reference external" href="https://github.com/python/cpython/issues/140212">gh-140212</a>.)</p></li>
|
||
<li><p>Calendar pages generated by the <a class="reference internal" href="../library/calendar.html#calendar.HTMLCalendar" title="calendar.HTMLCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">calendar.HTMLCalendar</span></code></a> class now support
|
||
dark mode and have been migrated to the HTML5 standard for improved accessibility.
|
||
(Contributed by Jiahao Li and Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/137634">gh-137634</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="collections">
|
||
<h3>collections<a class="headerlink" href="#collections" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added <code class="xref py py-meth docutils literal notranslate"><span class="pre">collections.Counter.__xor__()</span></code> and
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">collections.Counter.__ixor__()</span></code> to compute the symmetric difference
|
||
between <a class="reference internal" href="../library/collections.html#collections.Counter" title="collections.Counter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Counter</span></code></a> objects.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://github.com/python/cpython/issues/138682">gh-138682</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="concurrent-futures">
|
||
<h3>concurrent.futures<a class="headerlink" href="#concurrent-futures" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Improved error reporting when a child process in a
|
||
<a class="reference internal" href="../library/concurrent.futures.html#concurrent.futures.ProcessPoolExecutor" title="concurrent.futures.ProcessPoolExecutor"><code class="xref py py-class docutils literal notranslate"><span class="pre">concurrent.futures.ProcessPoolExecutor</span></code></a> terminates abruptly.
|
||
The resulting traceback will now tell you the PID and exit code of the
|
||
terminated process.
|
||
(Contributed by Jonathan Berg in <a class="reference external" href="https://github.com/python/cpython/issues/139486">gh-139486</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="contextlib">
|
||
<h3>contextlib<a class="headerlink" href="#contextlib" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added support for arbitrary descriptors <code class="xref py py-meth docutils literal notranslate"><span class="pre">__enter__()</span></code>,
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">__exit__()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">__aenter__()</span></code>, and <code class="xref py py-meth docutils literal notranslate"><span class="pre">__aexit__()</span></code> in
|
||
<a class="reference internal" href="../library/contextlib.html#contextlib.ExitStack" title="contextlib.ExitStack"><code class="xref py py-class docutils literal notranslate"><span class="pre">ExitStack</span></code></a> and <a class="reference internal" href="../library/contextlib.html#contextlib.AsyncExitStack" title="contextlib.AsyncExitStack"><code class="xref py py-class docutils literal notranslate"><span class="pre">contextlib.AsyncExitStack</span></code></a>, for
|
||
consistency with the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> and <a class="reference internal" href="../reference/compound_stmts.html#async-with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">async</span> <span class="pre">with</span></code></a> statements.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/144386">gh-144386</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/contextlib.html#contextlib.ContextDecorator" title="contextlib.ContextDecorator"><code class="xref py py-class docutils literal notranslate"><span class="pre">ContextDecorator</span></code></a> and
|
||
<a class="reference internal" href="../library/contextlib.html#contextlib.AsyncContextDecorator" title="contextlib.AsyncContextDecorator"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncContextDecorator</span></code></a> (and therefore
|
||
<a class="reference internal" href="../library/contextlib.html#contextlib.contextmanager" title="contextlib.contextmanager"><code class="xref py py-func docutils literal notranslate"><span class="pre">contextmanager()</span></code></a> and <a class="reference internal" href="../library/contextlib.html#contextlib.asynccontextmanager" title="contextlib.asynccontextmanager"><code class="xref py py-func docutils literal notranslate"><span class="pre">asynccontextmanager()</span></code></a>
|
||
used as decorators) now detect generator functions, coroutine functions, and
|
||
asynchronous generator functions and keep the context manager open across
|
||
iteration or await. Previously the context manager exited as soon as the
|
||
generator or coroutine object was created.
|
||
(Contributed by Alex Grönholm & Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/125862">gh-125862</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="ctypes">
|
||
<h3>ctypes<a class="headerlink" href="#ctypes" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Change the <a class="reference internal" href="../library/ctypes.html#ctypes._SimpleCData._type_" title="ctypes._SimpleCData._type_"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_type_</span></code></a> of
|
||
<a class="reference internal" href="../library/ctypes.html#ctypes.c_float_complex" title="ctypes.c_float_complex"><code class="xref py py-class docutils literal notranslate"><span class="pre">c_float_complex</span></code></a>, <a class="reference internal" href="../library/ctypes.html#ctypes.c_double_complex" title="ctypes.c_double_complex"><code class="xref py py-class docutils literal notranslate"><span class="pre">c_double_complex</span></code></a> and
|
||
<a class="reference internal" href="../library/ctypes.html#ctypes.c_longdouble_complex" title="ctypes.c_longdouble_complex"><code class="xref py py-class docutils literal notranslate"><span class="pre">c_longdouble_complex</span></code></a> from <code class="docutils literal notranslate"><span class="pre">F</span></code>, <code class="docutils literal notranslate"><span class="pre">D</span></code> and <code class="docutils literal notranslate"><span class="pre">G</span></code> to <code class="docutils literal notranslate"><span class="pre">Zf</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">Zd</span></code> and <code class="docutils literal notranslate"><span class="pre">Zg</span></code> for compatibility with NumPy.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/148675">gh-148675</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="dataclasses">
|
||
<h3>dataclasses<a class="headerlink" href="#dataclasses" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Annotations for generated <code class="docutils literal notranslate"><span class="pre">__init__</span></code> methods no longer include internal
|
||
type names.
|
||
(Contributed by David Ellis in <a class="reference external" href="https://github.com/python/cpython/issues/137530">gh-137530</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="dbm">
|
||
<h3>dbm<a class="headerlink" href="#dbm" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added new <code class="xref py py-meth docutils literal notranslate"><span class="pre">reorganize()</span></code> methods to <a class="reference internal" href="../library/dbm.html#module-dbm.dumb" title="dbm.dumb: Portable implementation of the simple DBM interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm.dumb</span></code></a> and <a class="reference internal" href="../library/dbm.html#module-dbm.sqlite3" title="dbm.sqlite3: SQLite backend for dbm"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dbm.sqlite3</span></code></a>
|
||
to recover unused free space previously occupied by deleted entries.
|
||
(Contributed by Andrea Oliveri in <a class="reference external" href="https://github.com/python/cpython/issues/134004">gh-134004</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="difflib">
|
||
<h3>difflib<a class="headerlink" href="#difflib" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-difflib">
|
||
<li><p>Introduced the optional <em>color</em> parameter to <a class="reference internal" href="../library/difflib.html#difflib.unified_diff" title="difflib.unified_diff"><code class="xref py py-func docutils literal notranslate"><span class="pre">difflib.unified_diff()</span></code></a>,
|
||
enabling color output similar to <strong class="program">git diff</strong>.
|
||
This can be controlled by <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Douglas Thor in <a class="reference external" href="https://github.com/python/cpython/issues/133725">gh-133725</a>.)</p></li>
|
||
<li><p>Improved the styling of HTML diff pages generated by the <a class="reference internal" href="../library/difflib.html#difflib.HtmlDiff" title="difflib.HtmlDiff"><code class="xref py py-class docutils literal notranslate"><span class="pre">difflib.HtmlDiff</span></code></a>
|
||
class, and migrated the output to the HTML5 standard.
|
||
(Contributed by Jiahao Li in <a class="reference external" href="https://github.com/python/cpython/issues/134580">gh-134580</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="email">
|
||
<h3>email<a class="headerlink" href="#email" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Email generators now raise an error when an <a class="reference internal" href="../library/email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> cannot be
|
||
accurately flattened due to a non-ASCII email address (mailbox) in an address
|
||
header. Options for supporting Email Address Internationalization (EAI) are
|
||
discussed in <a class="reference internal" href="../library/email.policy.html#email.policy.EmailPolicy.utf8" title="email.policy.EmailPolicy.utf8"><code class="xref py py-attr docutils literal notranslate"><span class="pre">EmailPolicy.utf8</span></code></a>.
|
||
(Contributed by R David Murray and Mike Edmunds in <a class="reference external" href="https://github.com/python/cpython/issues/122540">gh-122540</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="faulthandler">
|
||
<h3>faulthandler<a class="headerlink" href="#faulthandler" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added the <em>max_threads</em> parameter in <a class="reference internal" href="../library/faulthandler.html#faulthandler.enable" title="faulthandler.enable"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.enable()</span></code></a>,
|
||
<a class="reference internal" href="../library/faulthandler.html#faulthandler.dump_traceback" title="faulthandler.dump_traceback"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.dump_traceback()</span></code></a>, <a class="reference internal" href="../library/faulthandler.html#faulthandler.dump_traceback_later" title="faulthandler.dump_traceback_later"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.dump_traceback_later()</span></code></a>,
|
||
and <a class="reference internal" href="../library/faulthandler.html#faulthandler.register" title="faulthandler.register"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.register()</span></code></a>.
|
||
(Contributed by Eric Froemling in <a class="reference external" href="https://github.com/python/cpython/issues/149085">gh-149085</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="functools">
|
||
<h3>functools<a class="headerlink" href="#functools" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/functools.html#functools.singledispatchmethod" title="functools.singledispatchmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">singledispatchmethod()</span></code></a> now supports non-<a class="reference internal" href="../glossary.html#term-descriptor"><span class="xref std std-term">descriptor</span></a>
|
||
callables.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/140873">gh-140873</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/functools.html#functools.singledispatchmethod" title="functools.singledispatchmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">singledispatchmethod()</span></code></a> now dispatches on the second argument
|
||
if it wraps a regular method and is called as a class attribute.
|
||
(Contributed by Bartosz Sławecki in <a class="reference external" href="https://github.com/python/cpython/issues/143535">gh-143535</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="gc">
|
||
<h3>gc<a class="headerlink" href="#gc" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Python 3.14.0-3.14.4 shipped with a new incremental garbage collector.
|
||
However, due to a number of <a class="reference external" href="https://github.com/python/cpython/issues/142516">reports</a>
|
||
of significant memory pressure in production environments,
|
||
it has been reverted back to the generational GC from 3.13.
|
||
This is the GC now used in Python 3.14.5 and later and Python 3.15.
|
||
(Contributed by Sergey Miryanov in <a class="reference external" href="https://github.com/python/cpython/issues/148726">gh-148726</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="hashlib">
|
||
<h3>hashlib<a class="headerlink" href="#hashlib" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Ensure that hash functions guaranteed to be always <em>available</em> exist as
|
||
attributes of <a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a> even if they will not work at runtime due to
|
||
missing backend implementations. For instance, <code class="docutils literal notranslate"><span class="pre">hashlib.md5</span></code> will no
|
||
longer raise <a class="reference internal" href="../builtins/exceptions.html#AttributeError" title="AttributeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AttributeError</span></code></a> if OpenSSL is not available and Python
|
||
has been built without MD5 support.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/136929">gh-136929</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="http-client">
|
||
<h3>http.client<a class="headerlink" href="#http-client" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>A new <em>max_response_headers</em> keyword-only parameter has been added to
|
||
<a class="reference internal" href="../library/http.client.html#http.client.HTTPConnection" title="http.client.HTTPConnection"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPConnection</span></code></a> and <a class="reference internal" href="../library/http.client.html#http.client.HTTPSConnection" title="http.client.HTTPSConnection"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTTPSConnection</span></code></a>
|
||
constructors. This parameter overrides the default maximum number of allowed
|
||
response headers.
|
||
(Contributed by Alexander Enrique Urieles Nieto in <a class="reference external" href="https://github.com/python/cpython/issues/131724">gh-131724</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="http-server">
|
||
<h3>http.server<a class="headerlink" href="#http-server" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-http-server">
|
||
<li><p>The logging of <a class="reference internal" href="../library/http.server.html#http.server.BaseHTTPRequestHandler" title="http.server.BaseHTTPRequestHandler"><code class="xref py py-mod docutils literal notranslate"><span class="pre">BaseHTTPRequestHandler</span></code></a>,
|
||
as used by the <a class="reference internal" href="../library/http.server.html#http-server-cli"><span class="std std-ref">command-line interface</span></a>,
|
||
is colored by default.
|
||
This can be controlled with <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/146292">gh-146292</a>.)</p></li>
|
||
<li><p>Added <a class="reference internal" href="../library/http.server.html#http.server.SimpleHTTPRequestHandler.default_content_type" title="http.server.SimpleHTTPRequestHandler.default_content_type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">default_content_type</span></code></a>
|
||
and the <a class="reference internal" href="../library/http.server.html#cmdoption-http.server-content-type"><code class="xref std std-option docutils literal notranslate"><span class="pre">--content-type</span></code></a> command-line
|
||
option to allow customizing the default <code class="docutils literal notranslate"><span class="pre">Content-Type</span></code> header
|
||
for files with unknown extensions.
|
||
(Contributed by John Comeau and Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/113471">gh-113471</a>.)</p></li>
|
||
<li><p>Add a new <code class="docutils literal notranslate"><span class="pre">extra_response_headers</span></code> keyword argument to
|
||
<a class="reference internal" href="../library/http.server.html#http.server.SimpleHTTPRequestHandler" title="http.server.SimpleHTTPRequestHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleHTTPRequestHandler</span></code></a> to support custom headers in
|
||
HTTP responses.
|
||
(Contributed by Anton I. Sipos in <a class="reference external" href="https://github.com/python/cpython/issues/135057">gh-135057</a>.)</p></li>
|
||
<li><p>Add a <a class="reference internal" href="../library/http.server.html#cmdoption-http.server-H"><code class="xref std std-option docutils literal notranslate"><span class="pre">-H/--header</span></code></a> option to the <strong class="program">python -m http.server</strong>
|
||
command-line interface to support custom headers in HTTP responses.
|
||
(Contributed by Anton I. Sipos in <a class="reference external" href="https://github.com/python/cpython/issues/135057">gh-135057</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="importlib-metadata">
|
||
<h3>importlib.metadata<a class="headerlink" href="#importlib-metadata" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Previously, when accessing a distribution metadata directory not
|
||
containing a metadata file, <code class="docutils literal notranslate"><span class="pre">metadata()</span></code> and <code class="docutils literal notranslate"><span class="pre">Distribution.metadata</span></code>
|
||
would return an empty <code class="docutils literal notranslate"><span class="pre">PackageMetadata</span></code> object as if the file
|
||
was present but empty. Now, a <code class="docutils literal notranslate"><span class="pre">MetadataNotFound</span></code> exception is raised.
|
||
See <a class="reference external" href="https://github.com/python/importlib_metadata/issues/493">importlib_metadata#493</a>
|
||
for background and rationale and <a class="reference external" href="https://github.com/python/cpython/issues/143387">gh-143387</a> for rationale on the
|
||
compatibility concerns.
|
||
(Contributed by Jason R. Coombs.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="inspect">
|
||
<h3>inspect<a class="headerlink" href="#inspect" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add parameters <em>inherit_class_doc</em> and <em>fallback_to_class_doc</em>
|
||
for <a class="reference internal" href="../library/inspect.html#inspect.getdoc" title="inspect.getdoc"><code class="xref py py-func docutils literal notranslate"><span class="pre">getdoc()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/132686">gh-132686</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="json">
|
||
<h3>json<a class="headerlink" href="#json" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add the <em>array_hook</em> parameter to <a class="reference internal" href="../library/json.html#json.load" title="json.load"><code class="xref py py-func docutils literal notranslate"><span class="pre">load()</span></code></a> and
|
||
<a class="reference internal" href="../library/json.html#json.loads" title="json.loads"><code class="xref py py-func docutils literal notranslate"><span class="pre">loads()</span></code></a> functions:
|
||
allow a callback for JSON literal array types to customize Python lists in
|
||
the resulting decoded object. Passing combined <a class="reference internal" href="../builtins/stdtypes.html#frozendict" title="frozendict"><code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code></a> to
|
||
<em>object_pairs_hook</em> parameter and <a class="reference internal" href="../builtins/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a> to <em>array_hook</em> will yield a
|
||
deeply nested immutable Python structure representing the JSON data.
|
||
(Contributed by Joao S. O. Bueno in <a class="reference external" href="https://github.com/python/cpython/issues/146440">gh-146440</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="locale">
|
||
<h3>locale<a class="headerlink" href="#locale" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/locale.html#locale.setlocale" title="locale.setlocale"><code class="xref py py-func docutils literal notranslate"><span class="pre">setlocale()</span></code></a> now supports language codes with <code class="docutils literal notranslate"><span class="pre">@</span></code>-modifiers.
|
||
<code class="docutils literal notranslate"><span class="pre">@</span></code>-modifiers are no longer silently removed in <a class="reference internal" href="../library/locale.html#locale.getlocale" title="locale.getlocale"><code class="xref py py-func docutils literal notranslate"><span class="pre">getlocale()</span></code></a>,
|
||
but included in the language code.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/137729">gh-137729</a>.)</p></li>
|
||
<li><p>Undeprecate the <a class="reference internal" href="../library/locale.html#locale.getdefaultlocale" title="locale.getdefaultlocale"><code class="xref py py-func docutils literal notranslate"><span class="pre">locale.getdefaultlocale()</span></code></a> function.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/130796">gh-130796</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="math">
|
||
<h3>math<a class="headerlink" href="#math" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add <a class="reference internal" href="../library/math.html#math.isnormal" title="math.isnormal"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.isnormal()</span></code></a> and <a class="reference internal" href="../library/math.html#math.issubnormal" title="math.issubnormal"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.issubnormal()</span></code></a> functions.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/132908">gh-132908</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../library/math.html#math.fmax" title="math.fmax"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.fmax()</span></code></a>, <a class="reference internal" href="../library/math.html#math.fmin" title="math.fmin"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.fmin()</span></code></a> and <a class="reference internal" href="../library/math.html#math.signbit" title="math.signbit"><code class="xref py py-func docutils literal notranslate"><span class="pre">math.signbit()</span></code></a> functions.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/135853">gh-135853</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="mimetypes">
|
||
<h3>mimetypes<a class="headerlink" href="#mimetypes" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add more MIME types.
|
||
(Contributed by Benedikt Johannes, Charlie Lin, Foolbar, Gil Forcada and
|
||
John Franey
|
||
in <a class="reference external" href="https://github.com/python/cpython/issues/144217">gh-144217</a>, <a class="reference external" href="https://github.com/python/cpython/issues/145720">gh-145720</a>, <a class="reference external" href="https://github.com/python/cpython/issues/140937">gh-140937</a>, <a class="reference external" href="https://github.com/python/cpython/issues/139959">gh-139959</a>, <a class="reference external" href="https://github.com/python/cpython/issues/145698">gh-145698</a>,
|
||
<a class="reference external" href="https://github.com/python/cpython/issues/145718">gh-145718</a>, <a class="reference external" href="https://github.com/python/cpython/issues/145918">gh-145918</a>, and <a class="reference external" href="https://github.com/python/cpython/issues/144213">gh-144213</a>.)</p></li>
|
||
<li><p>Rename <code class="docutils literal notranslate"><span class="pre">application/x-texinfo</span></code> to <code class="docutils literal notranslate"><span class="pre">application/texinfo</span></code>.
|
||
(Contributed by Charlie Lin in <a class="reference external" href="https://github.com/python/cpython/issues/140165">gh-140165</a>.)</p></li>
|
||
<li><p>Changed the MIME type for <code class="docutils literal notranslate"><span class="pre">.ai</span></code> files to <code class="docutils literal notranslate"><span class="pre">application/pdf</span></code>.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/141239">gh-141239</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="mmap">
|
||
<h3>mmap<a class="headerlink" href="#mmap" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/mmap.html#mmap.mmap" title="mmap.mmap"><code class="xref py py-class docutils literal notranslate"><span class="pre">mmap.mmap</span></code></a> now has a <em>trackfd</em> parameter on Windows;
|
||
if it is <code class="docutils literal notranslate"><span class="pre">False</span></code>, the file handle corresponding to <em>fileno</em> will
|
||
not be duplicated.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/78502">gh-78502</a>.)</p></li>
|
||
<li><p>Added the <a class="reference internal" href="../library/mmap.html#mmap.mmap.set_name" title="mmap.mmap.set_name"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mmap.mmap.set_name()</span></code></a> method
|
||
to annotate an anonymous memory mapping
|
||
if Linux kernel supports <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/PR_SET_VMA(2const)">PR_SET_VMA_ANON_NAME</a></em> (Linux 5.17 or newer).
|
||
(Contributed by Donghee Na in <a class="reference external" href="https://github.com/python/cpython/issues/142419">gh-142419</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="os">
|
||
<h3>os<a class="headerlink" href="#os" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add <a class="reference internal" href="../library/os.html#os.statx" title="os.statx"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.statx()</span></code></a> on Linux kernel versions 4.11 and later with
|
||
glibc versions 2.28 and later.
|
||
(Contributed by Jeffrey Bosboom and Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/83714">gh-83714</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/os.html#os.makedirs" title="os.makedirs"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.makedirs()</span></code></a> function now has a <em>parent_mode</em> parameter that allows
|
||
specifying the mode for intermediate directories. This can be used to match
|
||
the behavior from Python 3.6 and earlier by passing <code class="docutils literal notranslate"><span class="pre">parent_mode=mode</span></code>.
|
||
(Contributed by Zackery Spytz and Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/86533">gh-86533</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="os-path">
|
||
<h3>os.path<a class="headerlink" href="#os-path" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add support of the all-but-last mode in <a class="reference internal" href="../library/os.path.html#os.path.realpath" title="os.path.realpath"><code class="xref py py-func docutils literal notranslate"><span class="pre">realpath()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/71189">gh-71189</a>.)</p></li>
|
||
<li><p>The <em>strict</em> parameter to <a class="reference internal" href="../library/os.path.html#os.path.realpath" title="os.path.realpath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.path.realpath()</span></code></a> accepts a new value,
|
||
<a class="reference internal" href="../library/os.path.html#os.path.ALLOW_MISSING" title="os.path.ALLOW_MISSING"><code class="xref py py-data docutils literal notranslate"><span class="pre">os.path.ALLOW_MISSING</span></code></a>.
|
||
If used, errors other than <a class="reference internal" href="../builtins/exceptions.html#FileNotFoundError" title="FileNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FileNotFoundError</span></code></a> will be re-raised;
|
||
the resulting path can be missing but it will be free of symlinks.
|
||
(Contributed by Petr Viktorin for <span class="target" id="index-45"></span><a class="cve reference external" href="https://www.cve.org/CVERecord?id=CVE-2025-4517"><strong>CVE 2025-4517</strong></a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="pathlib">
|
||
<h3>pathlib<a class="headerlink" href="#pathlib" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/pathlib.html#pathlib.Path.mkdir" title="pathlib.Path.mkdir"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pathlib.Path.mkdir()</span></code></a> now has a <em>parent_mode</em> parameter that allows
|
||
specifying the mode for intermediate directories when <code class="docutils literal notranslate"><span class="pre">parents=True</span></code>.
|
||
(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/86533">gh-86533</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="pdb">
|
||
<h3>pdb<a class="headerlink" href="#pdb" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Use the new interactive shell as the default input shell for <a class="reference internal" href="../library/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>.
|
||
(Contributed by Tian Gao in <a class="reference external" href="https://github.com/python/cpython/issues/145379">gh-145379</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="pickle">
|
||
<h3>pickle<a class="headerlink" href="#pickle" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add support for pickling private methods and nested classes.
|
||
(Contributed by Zackery Spytz and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/77188">gh-77188</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="pickletools">
|
||
<h3>pickletools<a class="headerlink" href="#pickletools" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-pickletools">
|
||
<li><p>The output of the <a class="reference internal" href="../library/pickletools.html#module-pickletools" title="pickletools: Contains extensive comments about the pickle protocols and pickle-machine opcodes, as well as some useful functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickletools</span></code></a> command-line interface is colored by
|
||
default. This can be controlled with
|
||
<a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/149026">gh-149026</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="pprint">
|
||
<h3>pprint<a class="headerlink" href="#pprint" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add an <em>expand</em> keyword argument for <a class="reference internal" href="../library/pprint.html#pprint.pprint" title="pprint.pprint"><code class="xref py py-func docutils literal notranslate"><span class="pre">pprint.pprint()</span></code></a>,
|
||
<a class="reference internal" href="../library/pprint.html#pprint.pformat" title="pprint.pformat"><code class="xref py py-func docutils literal notranslate"><span class="pre">pprint.pformat()</span></code></a>, <a class="reference internal" href="../library/pprint.html#pprint.pp" title="pprint.pp"><code class="xref py py-func docutils literal notranslate"><span class="pre">pprint.pp()</span></code></a>. If true, the output will be
|
||
formatted similar to pretty-printed <a class="reference internal" href="../library/json.html#json.dumps" title="json.dumps"><code class="xref py py-func docutils literal notranslate"><span class="pre">json.dumps()</span></code></a> when
|
||
<em>indent</em> is supplied.
|
||
(Contributed by Stefan Todoran, Semyon Moroz and Hugo van Kemenade in
|
||
<a class="reference external" href="https://github.com/python/cpython/issues/112632">gh-112632</a>.)</p></li>
|
||
<li><p>Add t-string support to <a class="reference internal" href="../library/pprint.html#module-pprint" title="pprint: Data pretty printer."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pprint</span></code></a>.
|
||
(Contributed by Loïc Simon and Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/134551">gh-134551</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="re">
|
||
<h3>re<a class="headerlink" href="#re" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/re.html#re.prefixmatch" title="re.prefixmatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.prefixmatch()</span></code></a> and a corresponding <a class="reference internal" href="../library/re.html#re.Pattern.prefixmatch" title="re.Pattern.prefixmatch"><code class="xref py py-meth docutils literal notranslate"><span class="pre">re.Pattern.prefixmatch()</span></code></a>
|
||
have been added as alternate, more explicit names for the existing
|
||
and now <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>
|
||
<a class="reference internal" href="../library/re.html#re.match" title="re.match"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.match()</span></code></a> and <a class="reference internal" href="../library/re.html#re.Pattern.match" title="re.Pattern.match"><code class="xref py py-meth docutils literal notranslate"><span class="pre">re.Pattern.match()</span></code></a> APIs. These are intended
|
||
to be used to alleviate confusion around what <em>match</em> means by following the
|
||
Zen of Python’s <em>“Explicit is better than implicit”</em> mantra. Most other
|
||
language regular expression libraries use an API named <em>match</em> to mean what
|
||
Python has always called <em>search</em>.
|
||
(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/86519">gh-86519</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="resource">
|
||
<h3>resource<a class="headerlink" href="#resource" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add new constants: <a class="reference internal" href="../library/resource.html#resource.RLIMIT_NTHR" title="resource.RLIMIT_NTHR"><code class="xref py py-data docutils literal notranslate"><span class="pre">RLIMIT_NTHR</span></code></a>,
|
||
<a class="reference internal" href="../library/resource.html#resource.RLIMIT_UMTXP" title="resource.RLIMIT_UMTXP"><code class="xref py py-data docutils literal notranslate"><span class="pre">RLIMIT_UMTXP</span></code></a>, <a class="reference internal" href="../library/resource.html#resource.RLIMIT_THREADS" title="resource.RLIMIT_THREADS"><code class="xref py py-data docutils literal notranslate"><span class="pre">RLIMIT_THREADS</span></code></a>,
|
||
<a class="reference internal" href="../library/resource.html#resource.RLIM_SAVED_CUR" title="resource.RLIM_SAVED_CUR"><code class="xref py py-data docutils literal notranslate"><span class="pre">RLIM_SAVED_CUR</span></code></a>, and <a class="reference internal" href="../library/resource.html#resource.RLIM_SAVED_MAX" title="resource.RLIM_SAVED_MAX"><code class="xref py py-data docutils literal notranslate"><span class="pre">RLIM_SAVED_MAX</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/137512">gh-137512</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="shelve">
|
||
<h3>shelve<a class="headerlink" href="#shelve" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added new <code class="xref py py-meth docutils literal notranslate"><span class="pre">reorganize()</span></code> method to <a class="reference internal" href="../library/shelve.html#module-shelve" title="shelve: Python object persistence."><code class="xref py py-mod docutils literal notranslate"><span class="pre">shelve</span></code></a> used to recover unused free
|
||
space previously occupied by deleted entries.
|
||
(Contributed by Andrea Oliveri in <a class="reference external" href="https://github.com/python/cpython/issues/134004">gh-134004</a>.)</p></li>
|
||
<li><p>Add support for custom serialization and deserialization functions
|
||
in the <a class="reference internal" href="../library/shelve.html#module-shelve" title="shelve: Python object persistence."><code class="xref py py-mod docutils literal notranslate"><span class="pre">shelve</span></code></a> module.
|
||
(Contributed by Furkan Onder in <a class="reference external" href="https://github.com/python/cpython/issues/99631">gh-99631</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="socket">
|
||
<h3>socket<a class="headerlink" href="#socket" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add constants for the ISO-TP CAN protocol.
|
||
(Contributed by Patrick Menschel and Stefan Tatschner in <a class="reference external" href="https://github.com/python/cpython/issues/86819">gh-86819</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="sqlite3">
|
||
<h3>sqlite3<a class="headerlink" href="#sqlite3" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>The <a class="reference internal" href="../library/sqlite3.html#sqlite3-cli"><span class="std std-ref">command-line interface</span></a> has several new features:</p>
|
||
<ul class="simple">
|
||
<li><p>SQL keyword completion on <kbd class="kbd docutils literal notranslate">Tab</kbd>.
|
||
(Contributed by Long Tan in <a class="reference external" href="https://github.com/python/cpython/issues/133393">gh-133393</a>.)</p></li>
|
||
</ul>
|
||
<ul class="simple" id="whatsnew315-color-sqlite3">
|
||
<li><p>Prompts, error messages, and help text are now colored.
|
||
This is enabled by default, see <a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">Controlling color</span></a> for
|
||
details.
|
||
(Contributed by Stan Ulbrych and Łukasz Langa in <a class="reference external" href="https://github.com/python/cpython/issues/133461">gh-133461</a>.)</p></li>
|
||
<li><p>Table, index, trigger, view, column, function, and schema completion on <kbd class="kbd docutils literal notranslate">Tab</kbd>.
|
||
(Contributed by Long Tan in <a class="reference external" href="https://github.com/python/cpython/issues/136101">gh-136101</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="ssl">
|
||
<h3>ssl<a class="headerlink" href="#ssl" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>Indicate through <a class="reference internal" href="../library/ssl.html#ssl.HAS_PSK_TLS13" title="ssl.HAS_PSK_TLS13"><code class="xref py py-data docutils literal notranslate"><span class="pre">ssl.HAS_PSK_TLS13</span></code></a> whether the <a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> module
|
||
supports “External PSKs” in TLSv1.3, as described in <span class="target" id="index-46"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc9258.html"><strong>RFC 9258</strong></a>.
|
||
(Contributed by Will Childs-Klein in <a class="reference external" href="https://github.com/python/cpython/issues/133624">gh-133624</a>.)</p></li>
|
||
<li><p>Added new methods for managing groups used for SSL key agreement:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_groups" title="ssl.SSLContext.set_groups"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.set_groups()</span></code></a> sets the groups allowed for doing
|
||
key agreement, extending the previous
|
||
<a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_ecdh_curve" title="ssl.SSLContext.set_ecdh_curve"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.set_ecdh_curve()</span></code></a> method.
|
||
This new API provides the ability to list multiple groups and
|
||
supports fixed-field and post-quantum groups in addition to ECDH
|
||
curves. This method can also be used to control what key shares
|
||
are sent in the TLS handshake.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLSocket.group" title="ssl.SSLSocket.group"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLSocket.group()</span></code></a> returns the group selected for doing key
|
||
agreement on the current connection after the TLS handshake completes.
|
||
This call requires OpenSSL 3.2 or later.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext.get_groups" title="ssl.SSLContext.get_groups"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.get_groups()</span></code></a> returns a list of all available key
|
||
agreement groups compatible with the minimum and maximum TLS versions
|
||
currently set in the context. This call requires OpenSSL 3.5 or later.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Ron Frederick in <a class="reference external" href="https://github.com/python/cpython/issues/136306">gh-136306</a>.)</p>
|
||
</li>
|
||
<li><p>Added a new method <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_ciphersuites" title="ssl.SSLContext.set_ciphersuites"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.set_ciphersuites()</span></code></a> for setting TLS 1.3
|
||
ciphers. For TLS 1.2 or earlier, <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_ciphers" title="ssl.SSLContext.set_ciphers"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.set_ciphers()</span></code></a> should
|
||
continue to be used. Both calls can be made on the same context and the
|
||
selected cipher suite will depend on the TLS version negotiated when a
|
||
connection is made.
|
||
(Contributed by Ron Frederick in <a class="reference external" href="https://github.com/python/cpython/issues/137197">gh-137197</a>.)</p></li>
|
||
<li><p>Added new methods for managing signature algorithms:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.get_sigalgs" title="ssl.get_sigalgs"><code class="xref py py-func docutils literal notranslate"><span class="pre">ssl.get_sigalgs()</span></code></a> returns a list of all available TLS signature
|
||
algorithms. This call requires OpenSSL 3.4 or later.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_client_sigalgs" title="ssl.SSLContext.set_client_sigalgs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.set_client_sigalgs()</span></code></a> sets the signature algorithms
|
||
allowed for certificate-based client authentication.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_server_sigalgs" title="ssl.SSLContext.set_server_sigalgs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLContext.set_server_sigalgs()</span></code></a> sets the signature algorithms
|
||
allowed for the server to complete the TLS handshake.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLSocket.client_sigalg" title="ssl.SSLSocket.client_sigalg"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLSocket.client_sigalg()</span></code></a> returns the signature algorithm
|
||
selected for client authentication on the current connection. This call
|
||
requires OpenSSL 3.5 or later.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLSocket.server_sigalg" title="ssl.SSLSocket.server_sigalg"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ssl.SSLSocket.server_sigalg()</span></code></a> returns the signature algorithm
|
||
selected for the server to complete the TLS handshake on the current
|
||
connection. This call requires OpenSSL 3.5 or later.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Ron Frederick in <a class="reference external" href="https://github.com/python/cpython/issues/138252">gh-138252</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="subprocess">
|
||
<h3>subprocess<a class="headerlink" href="#subprocess" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/subprocess.html#subprocess.Popen.wait" title="subprocess.Popen.wait"><code class="xref py py-meth docutils literal notranslate"><span class="pre">subprocess.Popen.wait()</span></code></a>: when <code class="docutils literal notranslate"><span class="pre">timeout</span></code> is not <code class="docutils literal notranslate"><span class="pre">None</span></code> and the
|
||
platform supports it, an efficient event-driven mechanism is used to wait for
|
||
process termination:</p>
|
||
<ul class="simple">
|
||
<li><p>Linux >= 5.3 uses <a class="reference internal" href="../library/os.html#os.pidfd_open" title="os.pidfd_open"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.pidfd_open()</span></code></a> + <a class="reference internal" href="../library/select.html#select.poll" title="select.poll"><code class="xref py py-func docutils literal notranslate"><span class="pre">select.poll()</span></code></a>.</p></li>
|
||
<li><p>macOS and other BSD variants use <a class="reference internal" href="../library/select.html#select.kqueue" title="select.kqueue"><code class="xref py py-func docutils literal notranslate"><span class="pre">select.kqueue()</span></code></a> + <code class="docutils literal notranslate"><span class="pre">KQ_FILTER_PROC</span></code> + <code class="docutils literal notranslate"><span class="pre">KQ_NOTE_EXIT</span></code>.</p></li>
|
||
<li><p>Windows keeps using <code class="docutils literal notranslate"><span class="pre">WaitForSingleObject</span></code> (unchanged).</p></li>
|
||
</ul>
|
||
<p>If none of these mechanisms are available, the function falls back to the
|
||
traditional busy loop (non-blocking call and short sleeps).
|
||
(Contributed by Giampaolo Rodola in <a class="reference external" href="https://github.com/python/cpython/issues/83069">gh-83069</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="symtable">
|
||
<h3>symtable<a class="headerlink" href="#symtable" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add <a class="reference internal" href="../library/symtable.html#symtable.Function.get_cells" title="symtable.Function.get_cells"><code class="xref py py-meth docutils literal notranslate"><span class="pre">symtable.Function.get_cells()</span></code></a> and <a class="reference internal" href="../library/symtable.html#symtable.Symbol.is_cell" title="symtable.Symbol.is_cell"><code class="xref py py-meth docutils literal notranslate"><span class="pre">symtable.Symbol.is_cell()</span></code></a> methods.
|
||
(Contributed by Yashp002 in <a class="reference external" href="https://github.com/python/cpython/issues/143504">gh-143504</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="sys">
|
||
<h3>sys<a class="headerlink" href="#sys" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add <a class="reference internal" href="../library/sys.html#sys.abi_info" title="sys.abi_info"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.abi_info</span></code></a> namespace to improve access to ABI information.
|
||
(Contributed by Klaus Zimmermann in <a class="reference external" href="https://github.com/python/cpython/issues/137476">gh-137476</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="sys-monitoring">
|
||
<h3>sys.monitoring<a class="headerlink" href="#sys-monitoring" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/sys.monitoring.html#monitoring-event-global"><span class="std std-ref">other events</span></a>
|
||
(<a class="reference internal" href="../library/sys.monitoring.html#monitoring-event-PY_THROW"><code class="xref std std-monitoring-event docutils literal notranslate"><span class="pre">PY_THROW</span></code></a>, <a class="reference internal" href="../library/sys.monitoring.html#monitoring-event-PY_UNWIND"><code class="xref std std-monitoring-event docutils literal notranslate"><span class="pre">PY_UNWIND</span></code></a>,
|
||
<a class="reference internal" href="../library/sys.monitoring.html#monitoring-event-RAISE"><code class="xref std std-monitoring-event docutils literal notranslate"><span class="pre">RAISE</span></code></a>, <a class="reference internal" href="../library/sys.monitoring.html#monitoring-event-EXCEPTION_HANDLED"><code class="xref std std-monitoring-event docutils literal notranslate"><span class="pre">EXCEPTION_HANDLED</span></code></a>, and
|
||
<a class="reference internal" href="../library/sys.monitoring.html#monitoring-event-RERAISE"><code class="xref std std-monitoring-event docutils literal notranslate"><span class="pre">RERAISE</span></code></a>) can now be turned on and disabled on a per code
|
||
object basis. Returning <a class="reference internal" href="../library/sys.monitoring.html#sys.monitoring.DISABLE" title="sys.monitoring.DISABLE"><code class="xref py py-data docutils literal notranslate"><span class="pre">DISABLE</span></code></a> from a callback for
|
||
one of these events disables the event for the entire code object (for the
|
||
current tool), rather than raising <a class="reference internal" href="../builtins/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> as in prior versions.
|
||
(Contributed by Gabriele N. Tornetta in <a class="reference external" href="https://github.com/python/cpython/issues/146182">gh-146182</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="tarfile">
|
||
<h3>tarfile<a class="headerlink" href="#tarfile" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#tarfile.data_filter" title="tarfile.data_filter"><code class="xref py py-func docutils literal notranslate"><span class="pre">data_filter()</span></code></a> now normalizes symbolic link targets in order to
|
||
avoid path traversal attacks.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/127987">gh-127987</a> and <span class="target" id="index-47"></span><a class="cve reference external" href="https://www.cve.org/CVERecord?id=CVE-2025-4138"><strong>CVE 2025-4138</strong></a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extractall" title="tarfile.TarFile.extractall"><code class="xref py py-func docutils literal notranslate"><span class="pre">extractall()</span></code></a> now skips fixing up directory attributes
|
||
when a directory was removed or replaced by another kind of file.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/127987">gh-127987</a> and <span class="target" id="index-48"></span><a class="cve reference external" href="https://www.cve.org/CVERecord?id=CVE-2024-12718"><strong>CVE 2024-12718</strong></a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extract" title="tarfile.TarFile.extract"><code class="xref py py-func docutils literal notranslate"><span class="pre">extract()</span></code></a> and <a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extractall" title="tarfile.TarFile.extractall"><code class="xref py py-func docutils literal notranslate"><span class="pre">extractall()</span></code></a>
|
||
now (re-)apply the extraction filter when substituting a link (hard or
|
||
symbolic) with a copy of another archive member, and when fixing up
|
||
directory attributes.
|
||
The former raises a new exception, <a class="reference internal" href="../library/tarfile.html#tarfile.LinkFallbackError" title="tarfile.LinkFallbackError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">LinkFallbackError</span></code></a>.
|
||
(Contributed by Petr Viktorin for <span class="target" id="index-49"></span><a class="cve reference external" href="https://www.cve.org/CVERecord?id=CVE-2025-4330"><strong>CVE 2025-4330</strong></a> and <span class="target" id="index-50"></span><a class="cve reference external" href="https://www.cve.org/CVERecord?id=CVE-2024-12718"><strong>CVE 2024-12718</strong></a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extract" title="tarfile.TarFile.extract"><code class="xref py py-func docutils literal notranslate"><span class="pre">extract()</span></code></a> and <a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extractall" title="tarfile.TarFile.extractall"><code class="xref py py-func docutils literal notranslate"><span class="pre">extractall()</span></code></a>
|
||
no longer extract rejected members when
|
||
<a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.errorlevel" title="tarfile.TarFile.errorlevel"><code class="xref py py-func docutils literal notranslate"><span class="pre">errorlevel()</span></code></a> is zero.
|
||
(Contributed by Matt Prodani and Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/112887">gh-112887</a>
|
||
and <span class="target" id="index-51"></span><a class="cve reference external" href="https://www.cve.org/CVERecord?id=CVE-2025-4435"><strong>CVE 2025-4435</strong></a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extract" title="tarfile.TarFile.extract"><code class="xref py py-func docutils literal notranslate"><span class="pre">extract()</span></code></a> and <a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.extractall" title="tarfile.TarFile.extractall"><code class="xref py py-func docutils literal notranslate"><span class="pre">extractall()</span></code></a>
|
||
now replace slashes with backslashes in symlink targets on Windows to prevent
|
||
creation of corrupted links.
|
||
(Contributed by Christoph Walcher in <a class="reference external" href="https://github.com/python/cpython/issues/57911">gh-57911</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#tarfile.TarFile.gettarinfo" title="tarfile.TarFile.gettarinfo"><code class="xref py py-func docutils literal notranslate"><span class="pre">gettarinfo()</span></code></a> now replaces backslashes with slashes in
|
||
symlink targets on Windows to conform to the tar format standard.
|
||
(Contributed by Daniele Nicolodi in <a class="reference external" href="https://github.com/python/cpython/issues/151669">gh-151669</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="threading">
|
||
<h3>threading<a class="headerlink" href="#threading" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added <a class="reference internal" href="../library/threading.html#threading.serialize_iterator" title="threading.serialize_iterator"><code class="xref py py-class docutils literal notranslate"><span class="pre">serialize_iterator</span></code></a>,
|
||
<a class="reference internal" href="../library/threading.html#threading.synchronized_iterator" title="threading.synchronized_iterator"><code class="xref py py-func docutils literal notranslate"><span class="pre">synchronized_iterator()</span></code></a>,
|
||
and <a class="reference internal" href="../library/threading.html#threading.concurrent_tee" title="threading.concurrent_tee"><code class="xref py py-func docutils literal notranslate"><span class="pre">concurrent_tee()</span></code></a> to support concurrent access to
|
||
generators and iterators.
|
||
(Contributed by Raymond Hettinger in <a class="reference external" href="https://github.com/python/cpython/issues/124397">gh-124397</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="timeit">
|
||
<h3>timeit<a class="headerlink" href="#timeit" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-timeit">
|
||
<li><p>The output of the <a class="reference internal" href="../library/timeit.html#module-timeit" title="timeit: Measure the execution time of small code snippets."><code class="xref py py-mod docutils literal notranslate"><span class="pre">timeit</span></code></a> command-line interface is colored by default.
|
||
This can be controlled with
|
||
<a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/146609">gh-146609</a>.)</p></li>
|
||
<li><p>The command-line interface now colorizes error tracebacks
|
||
by default. This can be controlled with
|
||
<a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Yi Hong in <a class="reference external" href="https://github.com/python/cpython/issues/139374">gh-139374</a>.)</p></li>
|
||
<li><p>Make the target time of <a class="reference internal" href="../library/timeit.html#timeit.Timer.autorange" title="timeit.Timer.autorange"><code class="xref py py-meth docutils literal notranslate"><span class="pre">timeit.Timer.autorange()</span></code></a> configurable
|
||
and add <code class="docutils literal notranslate"><span class="pre">--target-time</span></code> option to the command-line interface.
|
||
(Contributed by Alessandro Cucci and Miikka Koskinen in <a class="reference external" href="https://github.com/python/cpython/issues/80642">gh-80642</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="tkinter">
|
||
<h3>tkinter<a class="headerlink" href="#tkinter" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">tkinter.Text.search()</span></code> method now supports two additional
|
||
arguments: <em>nolinestop</em> which allows the search to
|
||
continue across line boundaries;
|
||
and <em>strictlimits</em> which restricts the search to within the specified range.
|
||
(Contributed by Rihaan Meher in <a class="reference external" href="https://github.com/python/cpython/issues/130848">gh-130848</a>.)</p></li>
|
||
<li><p>A new method <code class="xref py py-meth docutils literal notranslate"><span class="pre">tkinter.Text.search_all()</span></code> has been introduced.
|
||
This method allows for searching for all matches of a pattern
|
||
using Tcl’s <code class="docutils literal notranslate"><span class="pre">-all</span></code> and <code class="docutils literal notranslate"><span class="pre">-overlap</span></code> options.
|
||
(Contributed by Rihaan Meher in <a class="reference external" href="https://github.com/python/cpython/issues/130848">gh-130848</a>.)</p></li>
|
||
<li><p>Added new methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">pack_content()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">place_content()</span></code> and
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">grid_content()</span></code> which use Tk commands with new names (introduced
|
||
in Tk 8.6) instead of <code class="xref py py-meth docutils literal notranslate"><span class="pre">*_slaves()</span></code> methods which use Tk commands
|
||
with outdated names.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143754">gh-143754</a>.)</p></li>
|
||
<li><p>Added <code class="xref py py-class docutils literal notranslate"><span class="pre">Event</span></code> attributes <code class="xref py py-attr docutils literal notranslate"><span class="pre">user_data</span></code> for Tk virtual events
|
||
and <code class="xref py py-attr docutils literal notranslate"><span class="pre">detail</span></code> for <code class="docutils literal notranslate"><span class="pre">Enter</span></code>, <code class="docutils literal notranslate"><span class="pre">Leave</span></code>, <code class="docutils literal notranslate"><span class="pre">FocusIn</span></code>, <code class="docutils literal notranslate"><span class="pre">FocusOut</span></code>,
|
||
and <code class="docutils literal notranslate"><span class="pre">ConfigureRequest</span></code> events.
|
||
(Contributed by Matthias Kievernagel and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/47655">gh-47655</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="tokenize">
|
||
<h3>tokenize<a class="headerlink" href="#tokenize" title="Link to this heading">¶</a></h3>
|
||
<blockquote>
|
||
<div></div></blockquote>
|
||
<ul class="simple" id="whatsnew315-color-tokenize">
|
||
<li><p>The output of the <a class="reference internal" href="../library/tokenize.html#module-tokenize" title="tokenize: Lexical scanner for Python source code."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tokenize</span></code></a> <a class="reference internal" href="../library/tokenize.html#tokenize-cli"><span class="std std-ref">command-line interface</span></a> is colored by default. This can be controlled with
|
||
<a class="reference internal" href="../using/cmdline.html#using-on-controlling-color"><span class="std std-ref">environment variables</span></a>.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/148991">gh-148991</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="tomllib">
|
||
<span id="whatsnew315-tomllib-1-1-0"></span><h3>tomllib<a class="headerlink" href="#tomllib" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>The <a class="reference internal" href="../library/tomllib.html#module-tomllib" title="tomllib: Parse TOML files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tomllib</span></code></a> module now supports TOML 1.1.0.
|
||
This is a backwards compatible update, meaning that all valid TOML 1.0.0
|
||
documents are parsed the same way.</p>
|
||
<p>The changes, according to the <a class="reference external" href="https://github.com/toml-lang/toml/blob/main/CHANGELOG.md">official TOML changelog</a>, are:</p>
|
||
<ul>
|
||
<li><p>Allow newlines and trailing commas in inline tables.</p>
|
||
<p>Previously an inline table had to be on a single line and couldn’t end
|
||
with a trailing comma. This is now relaxed so that the following is valid:</p>
|
||
<div class="highlight-toml notranslate"><div class="highlight"><pre><span></span><span class="n">tbl</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span>
|
||
<span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="s2">"a string"</span><span class="p">,</span>
|
||
<span class="w"> </span><span class="n">moar-tbl</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="p">{</span>
|
||
<span class="w"> </span><span class="n">key</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span>
|
||
<span class="w"> </span><span class="p">},</span>
|
||
<span class="p">}</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Add <code class="docutils literal notranslate"><span class="pre">\xHH</span></code> notation to basic strings for codepoints under 255,
|
||
and the <code class="docutils literal notranslate"><span class="pre">\e</span></code> escape for the escape character:</p>
|
||
<div class="highlight-toml notranslate"><div class="highlight"><pre><span></span><span class="n">null</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"null byte: </span><span class="se">\x00</span><span class="s2">; letter a: </span><span class="se">\x61</span><span class="s2">"</span>
|
||
<span class="n">csi</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"</span><span class="se">\e</span><span class="s2">["</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
<li><p>Seconds in datetime and time values are now optional.
|
||
The following are now valid:</p>
|
||
<div class="highlight-toml notranslate"><div class="highlight"><pre><span></span><span class="n">dt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ld">2010-02-03 14:15</span>
|
||
<span class="n">t</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ld">14:15</span>
|
||
</pre></div>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
<p>(Contributed by Taneli Hukkinen in <a class="reference external" href="https://github.com/python/cpython/issues/142956">gh-142956</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="types">
|
||
<h3>types<a class="headerlink" href="#types" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Expose the write-through <a class="reference internal" href="../builtins/functions.html#locals" title="locals"><code class="xref py py-func docutils literal notranslate"><span class="pre">locals()</span></code></a> proxy type
|
||
as <a class="reference internal" href="../library/types.html#types.FrameLocalsProxyType" title="types.FrameLocalsProxyType"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.FrameLocalsProxyType</span></code></a>.
|
||
This represents the type of the <a class="reference internal" href="../reference/datamodel.html#frame.f_locals" title="frame.f_locals"><code class="xref py py-attr docutils literal notranslate"><span class="pre">frame.f_locals</span></code></a> attribute,
|
||
as described in <span class="target" id="index-52"></span><a class="pep reference external" href="https://peps.python.org/pep-0667/"><strong>PEP 667</strong></a>.
|
||
(Contributed by Peter Bierma in <a class="reference external" href="https://github.com/python/cpython/issues/136492">gh-136492</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="typing">
|
||
<h3>typing<a class="headerlink" href="#typing" title="Link to this heading">¶</a></h3>
|
||
<ul id="whatsnew315-typeform">
|
||
<li><p><span class="target" id="index-53"></span><a class="pep reference external" href="https://peps.python.org/pep-0747/"><strong>PEP 747</strong></a>: Add <a class="reference internal" href="../library/typing.html#typing.TypeForm" title="typing.TypeForm"><code class="xref py py-data docutils literal notranslate"><span class="pre">TypeForm</span></code></a>, a new special form for annotating
|
||
values that are themselves type expressions.
|
||
<code class="docutils literal notranslate"><span class="pre">TypeForm[T]</span></code> means “a type form object describing <code class="docutils literal notranslate"><span class="pre">T</span></code> (or a type
|
||
assignable to <code class="docutils literal notranslate"><span class="pre">T</span></code>)”. At runtime, <code class="docutils literal notranslate"><span class="pre">TypeForm(x)</span></code> simply returns <code class="docutils literal notranslate"><span class="pre">x</span></code>,
|
||
which allows explicit annotation of type-form values without changing
|
||
behavior.</p>
|
||
<p>This helps libraries that accept user-provided type expressions
|
||
(for example <code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">str</span> <span class="pre">|</span> <span class="pre">None</span></code>, <a class="reference internal" href="../library/typing.html#typing.TypedDict" title="typing.TypedDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypedDict</span></code></a>
|
||
classes, or <code class="docutils literal notranslate"><span class="pre">list[int]</span></code>) expose precise signatures:</p>
|
||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">TypeForm</span>
|
||
|
||
<span class="k">def</span><span class="w"> </span><span class="nf">cast</span><span class="p">[</span><span class="n">T</span><span class="p">](</span><span class="n">typ</span><span class="p">:</span> <span class="n">TypeForm</span><span class="p">[</span><span class="n">T</span><span class="p">],</span> <span class="n">value</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span> <span class="o">...</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Jelle Zijlstra in <a class="reference external" href="https://github.com/python/cpython/issues/145033">gh-145033</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
<ul class="simple" id="whatsnew315-typeddict">
|
||
<li><p><span class="target" id="index-54"></span><a class="pep reference external" href="https://peps.python.org/pep-0728/"><strong>PEP 728</strong></a>: Add support in <a class="reference internal" href="../library/typing.html#typing.TypedDict" title="typing.TypedDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypedDict</span></code></a> for the <em>closed</em>
|
||
and <em>extra_items</em> class arguments. A closed <code class="xref py py-class docutils literal notranslate"><span class="pre">TypedDict</span></code>
|
||
does not allow extra keys beyond those specified in the class body, while
|
||
a <code class="xref py py-class docutils literal notranslate"><span class="pre">TypedDict</span></code> with <code class="docutils literal notranslate"><span class="pre">extra_items</span></code> allows arbitrary extra
|
||
items where the values are of the specified type. (Contributed by Angela
|
||
Liss in <a class="reference external" href="https://github.com/python/cpython/issues/137840">gh-137840</a>.)</p></li>
|
||
<li><p>Code like <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">ExtraTypeVars(P1[S],</span> <span class="pre">Protocol[T,</span> <span class="pre">T2]):</span> <span class="pre">...</span></code> now raises
|
||
a <a class="reference internal" href="../builtins/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>, because <code class="docutils literal notranslate"><span class="pre">S</span></code> is not listed in <code class="docutils literal notranslate"><span class="pre">Protocol</span></code> parameters.
|
||
(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/137191">gh-137191</a>.)</p></li>
|
||
<li><p>Code like <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">B2(A[T2],</span> <span class="pre">Protocol[T1,</span> <span class="pre">T2]):</span> <span class="pre">...</span></code> now correctly handles
|
||
type parameters order: it is <code class="docutils literal notranslate"><span class="pre">(T1,</span> <span class="pre">T2)</span></code>, not <code class="docutils literal notranslate"><span class="pre">(T2,</span> <span class="pre">T1)</span></code>
|
||
as it was incorrectly inferred at runtime before.
|
||
(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/137191">gh-137191</a>.)</p>
|
||
</li>
|
||
<li id="whatsnew315-disjoint-base"><p><span class="target" id="index-55"></span><a class="pep reference external" href="https://peps.python.org/pep-0800/"><strong>PEP 800</strong></a>: Add <a class="reference internal" href="../library/typing.html#typing.disjoint_base" title="typing.disjoint_base"><code class="xref py py-deco docutils literal notranslate"><span class="pre">@typing.disjoint_base</span></code></a>, a new decorator marking a class
|
||
as a disjoint base. This is an advanced feature primarily intended to allow
|
||
type checkers to faithfully reflect the runtime semantics of types defined
|
||
as builtins or in compiled extensions. If a class <code class="docutils literal notranslate"><span class="pre">C</span></code> is a disjoint base, then
|
||
child classes of that class cannot inherit from other disjoint bases that are
|
||
not parent or child classes of <code class="docutils literal notranslate"><span class="pre">C</span></code>. (Contributed by Jelle Zijlstra in <a class="reference external" href="https://github.com/python/cpython/issues/148639">gh-148639</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/typing.html#typing.TypeVarTuple" title="typing.TypeVarTuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypeVarTuple</span></code></a> now accepts <code class="docutils literal notranslate"><span class="pre">bound</span></code>, <code class="docutils literal notranslate"><span class="pre">covariant</span></code>,
|
||
<code class="docutils literal notranslate"><span class="pre">contravariant</span></code>, and <code class="docutils literal notranslate"><span class="pre">infer_variance</span></code> keyword arguments, matching the
|
||
interface of <a class="reference internal" href="../library/typing.html#typing.TypeVar" title="typing.TypeVar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypeVar</span></code></a> and <a class="reference internal" href="../library/typing.html#typing.ParamSpec" title="typing.ParamSpec"><code class="xref py py-class docutils literal notranslate"><span class="pre">ParamSpec</span></code></a>.
|
||
<code class="docutils literal notranslate"><span class="pre">bound</span></code> semantics remain undefined in the specification.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="unicodedata">
|
||
<h3>unicodedata<a class="headerlink" href="#unicodedata" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The Unicode database has been updated to Unicode 17.0.0.
|
||
(Contributed by Benjamin Peterson in <a class="reference external" href="https://github.com/python/cpython/issues/138706">gh-138706</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../library/unicodedata.html#unicodedata.isxidstart" title="unicodedata.isxidstart"><code class="xref py py-func docutils literal notranslate"><span class="pre">unicodedata.isxidstart()</span></code></a> and <a class="reference internal" href="../library/unicodedata.html#unicodedata.isxidcontinue" title="unicodedata.isxidcontinue"><code class="xref py py-func docutils literal notranslate"><span class="pre">unicodedata.isxidcontinue()</span></code></a>
|
||
functions to check whether a character can start or continue a
|
||
<a class="reference external" href="https://www.unicode.org/reports/tr31/">Unicode Standard Annex #31</a> identifier.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/129117">gh-129117</a>.)</p></li>
|
||
<li><p>Add the <a class="reference internal" href="../library/unicodedata.html#unicodedata.iter_graphemes" title="unicodedata.iter_graphemes"><code class="xref py py-func docutils literal notranslate"><span class="pre">iter_graphemes()</span></code></a>
|
||
function to iterate over grapheme clusters according to rules defined in
|
||
<a class="reference external" href="https://www.unicode.org/reports/tr29/">Unicode Standard Annex #29, “Unicode Text Segmentation”</a>.
|
||
Add <a class="reference internal" href="../library/unicodedata.html#unicodedata.grapheme_cluster_break" title="unicodedata.grapheme_cluster_break"><code class="xref py py-func docutils literal notranslate"><span class="pre">grapheme_cluster_break()</span></code></a>,
|
||
<a class="reference internal" href="../library/unicodedata.html#unicodedata.indic_conjunct_break" title="unicodedata.indic_conjunct_break"><code class="xref py py-func docutils literal notranslate"><span class="pre">indic_conjunct_break()</span></code></a> and
|
||
<a class="reference internal" href="../library/unicodedata.html#unicodedata.extended_pictographic" title="unicodedata.extended_pictographic"><code class="xref py py-func docutils literal notranslate"><span class="pre">extended_pictographic()</span></code></a> functions to get the properties
|
||
of the character which are related to the above algorithm.
|
||
(Contributed by Serhiy Storchaka and Guillaume Sanchez in <a class="reference external" href="https://github.com/python/cpython/issues/74902">gh-74902</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../library/unicodedata.html#unicodedata.block" title="unicodedata.block"><code class="xref py py-func docutils literal notranslate"><span class="pre">block()</span></code></a> function to return the <a class="reference external" href="https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/#G64189">Unicode block</a>
|
||
assigned to a character.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/66802">gh-66802</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="unittest">
|
||
<h3>unittest<a class="headerlink" href="#unittest" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/unittest.html#unittest.TestCase.assertLogs" title="unittest.TestCase.assertLogs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unittest.TestCase.assertLogs()</span></code></a> will now accept a formatter
|
||
to control how messages are formatted.
|
||
(Contributed by Garry Cairns in <a class="reference external" href="https://github.com/python/cpython/issues/134567">gh-134567</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/unittest.html#unittest.TestCase.assertWarns" title="unittest.TestCase.assertWarns"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unittest.TestCase.assertWarns()</span></code></a> and
|
||
<a class="reference internal" href="../library/unittest.html#unittest.TestCase.assertWarnsRegex" title="unittest.TestCase.assertWarnsRegex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unittest.TestCase.assertWarnsRegex()</span></code></a> no longer swallow warnings that
|
||
do not match the specified category or regex.
|
||
Nested context managers are now supported.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143231">gh-143231</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="urllib-parse">
|
||
<h3>urllib.parse<a class="headerlink" href="#urllib-parse" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add the <em>missing_as_none</em> parameter to <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlsplit" title="urllib.parse.urlsplit"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlsplit()</span></code></a>,
|
||
<a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlparse" title="urllib.parse.urlparse"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlparse()</span></code></a> and <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urldefrag" title="urllib.parse.urldefrag"><code class="xref py py-func docutils literal notranslate"><span class="pre">urldefrag()</span></code></a> functions.
|
||
Add the <em>keep_empty</em> parameter to <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlunsplit" title="urllib.parse.urlunsplit"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlunsplit()</span></code></a> and
|
||
<a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlunparse" title="urllib.parse.urlunparse"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlunparse()</span></code></a> functions.
|
||
This allows distinguishing between empty and undefined URI components
|
||
and preserving empty components.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/67041">gh-67041</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="venv">
|
||
<h3>venv<a class="headerlink" href="#venv" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>On POSIX platforms, platlib directories will be created if needed when
|
||
creating virtual environments, instead of using a <code class="docutils literal notranslate"><span class="pre">lib64</span> <span class="pre">-></span> <span class="pre">lib</span></code> symlink.
|
||
This means purelib and platlib of virtual environments no longer share the
|
||
same <code class="docutils literal notranslate"><span class="pre">lib</span></code> directory on platforms where <a class="reference internal" href="../library/sys.html#sys.platlibdir" title="sys.platlibdir"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.platlibdir</span></code></a> is not
|
||
equal to <code class="docutils literal notranslate"><span class="pre">lib</span></code>.
|
||
(Contributed by Rui Xi in <a class="reference external" href="https://github.com/python/cpython/issues/133951">gh-133951</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="warnings">
|
||
<h3>warnings<a class="headerlink" href="#warnings" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Improve filtering by module in <a class="reference internal" href="../library/warnings.html#warnings.warn_explicit" title="warnings.warn_explicit"><code class="xref py py-func docutils literal notranslate"><span class="pre">warnings.warn_explicit()</span></code></a> if no <em>module</em>
|
||
argument is passed.
|
||
It now tests the module regular expression in the warnings filter not only
|
||
against the filename with <code class="docutils literal notranslate"><span class="pre">.py</span></code> stripped, but also against module names
|
||
constructed starting from different parent directories of the filename
|
||
(with <code class="docutils literal notranslate"><span class="pre">/__init__.py</span></code>, <code class="docutils literal notranslate"><span class="pre">.py</span></code> and, on Windows, <code class="docutils literal notranslate"><span class="pre">.pyw</span></code> stripped).
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/135801">gh-135801</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="wave">
|
||
<h3>wave<a class="headerlink" href="#wave" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Added support for IEEE floating-point WAVE audio
|
||
(<code class="docutils literal notranslate"><span class="pre">WAVE_FORMAT_IEEE_FLOAT</span></code>) in <a class="reference internal" href="../library/wave.html#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a>.</p></li>
|
||
<li><p>Added <a class="reference internal" href="../library/wave.html#wave.Wave_read.getformat" title="wave.Wave_read.getformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wave.Wave_read.getformat()</span></code></a>, <a class="reference internal" href="../library/wave.html#wave.Wave_write.getformat" title="wave.Wave_write.getformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wave.Wave_write.getformat()</span></code></a>,
|
||
and <a class="reference internal" href="../library/wave.html#wave.Wave_write.setformat" title="wave.Wave_write.setformat"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wave.Wave_write.setformat()</span></code></a> for explicit frame format handling.</p></li>
|
||
<li><p><a class="reference internal" href="../library/wave.html#wave.Wave_write.setparams" title="wave.Wave_write.setparams"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wave.Wave_write.setparams()</span></code></a> accepts both 7-item tuples including
|
||
<code class="docutils literal notranslate"><span class="pre">format</span></code> and 6-item tuples for backwards compatibility (defaulting to
|
||
<code class="docutils literal notranslate"><span class="pre">WAVE_FORMAT_PCM</span></code>).</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">WAVE_FORMAT_IEEE_FLOAT</span></code> output now includes a <code class="docutils literal notranslate"><span class="pre">fact</span></code> chunk,
|
||
as required for non-PCM WAVE formats.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Lionel Koenig and Michiel W. Beijen in <a class="reference external" href="https://github.com/python/cpython/issues/60729">gh-60729</a>.)</p>
|
||
</section>
|
||
<section id="webbrowser">
|
||
<h3>webbrowser<a class="headerlink" href="#webbrowser" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>On macOS, the new <code class="xref py py-class docutils literal notranslate"><span class="pre">webbrowser.MacOS</span></code> class opens URLs via
|
||
<strong class="program">/usr/bin/open</strong> instead of constructing and executing AppleScript
|
||
via <strong class="program">osascript</strong>. The default browser is detected from the
|
||
LaunchServices preferences file using <a class="reference internal" href="../library/plistlib.html#module-plistlib" title="plistlib: Generate and parse Apple plist files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">plistlib</span></code></a>, with
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">com.apple.Safari</span></code> as the fallback on fresh installations.
|
||
For non-HTTP(S) URLs, <strong class="program">open -b <bundle-id></strong> is used to route the
|
||
URL through a browser rather than the OS file handler, preventing
|
||
file injection attacks.
|
||
(Contributed by Jeff Lyon in <a class="reference external" href="https://github.com/python/cpython/issues/137586">gh-137586</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="xml">
|
||
<h3>xml<a class="headerlink" href="#xml" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add the <a class="reference internal" href="../library/xml.html#xml.is_valid_name" title="xml.is_valid_name"><code class="xref py py-func docutils literal notranslate"><span class="pre">xml.is_valid_name()</span></code></a> function to check
|
||
whether a string can be used as an element or attribute name in XML.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/139489">gh-139489</a>.)</p></li>
|
||
<li><p>Add the <a class="reference internal" href="../library/xml.html#xml.is_valid_text" title="xml.is_valid_text"><code class="xref py py-func docutils literal notranslate"><span class="pre">xml.is_valid_text()</span></code></a> function to check
|
||
whether a string can be used in an XML document.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/139489">gh-139489</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="xml-parsers-expat">
|
||
<h3>xml.parsers.expat<a class="headerlink" href="#xml-parsers-expat" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Add <a class="reference internal" href="../library/pyexpat.html#xml.parsers.expat.xmlparser.SetAllocTrackerActivationThreshold" title="xml.parsers.expat.xmlparser.SetAllocTrackerActivationThreshold"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetAllocTrackerActivationThreshold()</span></code></a>
|
||
and <a class="reference internal" href="../library/pyexpat.html#xml.parsers.expat.xmlparser.SetAllocTrackerMaximumAmplification" title="xml.parsers.expat.xmlparser.SetAllocTrackerMaximumAmplification"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetAllocTrackerMaximumAmplification()</span></code></a>
|
||
to <a class="reference internal" href="../library/pyexpat.html#xmlparser-objects"><span class="std std-ref">xmlparser</span></a> objects to tune protections against
|
||
disproportional amounts of dynamic memory usage from within an Expat parser.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/90949">gh-90949</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../library/pyexpat.html#xml.parsers.expat.xmlparser.SetBillionLaughsAttackProtectionActivationThreshold" title="xml.parsers.expat.xmlparser.SetBillionLaughsAttackProtectionActivationThreshold"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetBillionLaughsAttackProtectionActivationThreshold()</span></code></a>
|
||
and <a class="reference internal" href="../library/pyexpat.html#xml.parsers.expat.xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification" title="xml.parsers.expat.xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification"><code class="xref py py-meth docutils literal notranslate"><span class="pre">SetBillionLaughsAttackProtectionMaximumAmplification()</span></code></a>
|
||
to <a class="reference internal" href="../library/pyexpat.html#xmlparser-objects"><span class="std std-ref">xmlparser</span></a> objects to tune protections against
|
||
<a class="reference external" href="https://en.wikipedia.org/wiki/Billion_laughs_attack">billion laughs</a> attacks.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/90949">gh-90949</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="zlib">
|
||
<h3>zlib<a class="headerlink" href="#zlib" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Allow combining two Adler-32 checksums via <a class="reference internal" href="../library/zlib.html#zlib.adler32_combine" title="zlib.adler32_combine"><code class="xref py py-func docutils literal notranslate"><span class="pre">adler32_combine()</span></code></a>.
|
||
(Contributed by Callum Attryde and Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/134635">gh-134635</a>.)</p></li>
|
||
<li><p>Allow combining two CRC-32 checksums via <a class="reference internal" href="../library/zlib.html#zlib.crc32_combine" title="zlib.crc32_combine"><code class="xref py py-func docutils literal notranslate"><span class="pre">crc32_combine()</span></code></a>.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/134635">gh-134635</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
<section id="optimizations">
|
||
<h2>Optimizations<a class="headerlink" href="#optimizations" title="Link to this heading">¶</a></h2>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">mimalloc</span></code> is now used as the default allocator for
|
||
raw memory allocations such as via <a class="reference internal" href="../c-api/memory.html#c.PyMem_RawMalloc" title="PyMem_RawMalloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_RawMalloc()</span></code></a>
|
||
for better performance on <a class="reference internal" href="../glossary.html#term-free-threaded-build"><span class="xref std std-term">free-threaded builds</span></a>.
|
||
(Contributed by Kumar Aditya in <a class="reference external" href="https://github.com/python/cpython/issues/144914">gh-144914</a>.)</p></li>
|
||
</ul>
|
||
<section id="base64-binascii">
|
||
<h3>base64 & binascii<a class="headerlink" href="#base64-binascii" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>CPython’s underlying base64 implementation now encodes 2x faster and decodes 3x
|
||
faster thanks to simple CPU pipelining optimizations.
|
||
(Contributed by Gregory P. Smith and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143262">gh-143262</a>.)</p></li>
|
||
<li><p>Implementation for Ascii85, Base85, and Z85 encoding has been rewritten in C.
|
||
Encoding and decoding is now two orders of magnitude faster and consumes
|
||
two orders of magnitude less memory.
|
||
(Contributed by James Seo and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/101178">gh-101178</a>.)</p></li>
|
||
<li><p>Implementation for Base32 has been rewritten in C.
|
||
Encoding and decoding is now two orders of magnitude faster.
|
||
(Contributed by James Seo in <a class="reference external" href="https://github.com/python/cpython/issues/146192">gh-146192</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="csv">
|
||
<h3>csv<a class="headerlink" href="#csv" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/csv.html#csv.Sniffer.sniff" title="csv.Sniffer.sniff"><code class="xref py py-meth docutils literal notranslate"><span class="pre">csv.Sniffer.sniff()</span></code></a> delimiter detection is now up to 1.6x faster.
|
||
(Contributed by Maurycy Pawłowski-Wieroński in <a class="reference external" href="https://github.com/python/cpython/issues/137628">gh-137628</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="upgraded-experimental-jit-compiler">
|
||
<span id="whatsnew315-jit"></span><h3>Upgraded experimental JIT compiler<a class="headerlink" href="#upgraded-experimental-jit-compiler" title="Link to this heading">¶</a></h3>
|
||
<p>Results from the <a class="reference external" href="https://github.com/python/pyperformance">pyperformance</a>
|
||
benchmark suite report a
|
||
<a class="reference external" href="https://www.doesjitgobrrr.com/run/2026-09-25">7-8%</a>
|
||
geometric mean performance improvement for the JIT over the standard CPython
|
||
interpreter built with all optimizations enabled on x86-64 Linux. On AArch64
|
||
macOS, the JIT has an
|
||
<a class="reference external" href="https://www.doesjitgobrrr.com/run/2026-09-25">11-12%</a>
|
||
speedup over the <a class="reference internal" href="3.14.html#whatsnew314-tail-call-interpreter"><span class="std std-ref">tail calling interpreter</span></a>
|
||
with all optimizations enabled. The speedups for JIT
|
||
builds versus no JIT builds range from roughly 15% slowdown to over
|
||
100% speedup (ignoring the <code class="docutils literal notranslate"><span class="pre">unpack_sequence</span></code> microbenchmark) on
|
||
x86-64 Linux and AArch64 macOS systems.</p>
|
||
<p>The major upgrades to the JIT are:</p>
|
||
<ul class="simple">
|
||
<li><p>LLVM 21 build-time dependency</p></li>
|
||
<li><p>New tracing frontend</p></li>
|
||
<li><p>Basic register allocation in the JIT</p></li>
|
||
<li><p>More JIT optimizations</p></li>
|
||
<li><p>GDB and GNU <code class="docutils literal notranslate"><span class="pre">backtrace()</span></code> unwinding support</p></li>
|
||
<li><p>Better machine code generation</p></li>
|
||
</ul>
|
||
<p class="rubric">LLVM 21 build-time dependency</p>
|
||
<p>The JIT compiler now uses LLVM 21 for build-time stencil generation. As
|
||
always, LLVM is only needed when building CPython with the JIT enabled;
|
||
end users running Python do not need LLVM installed. Instructions for
|
||
installing LLVM can be found in the <a class="reference external" href="https://github.com/python/cpython/blob/main/Tools/jit/README.md">JIT compiler documentation</a>
|
||
for all supported platforms.
|
||
(Contributed by Savannah Ostrowski in <a class="reference external" href="https://github.com/python/cpython/issues/140973">gh-140973</a>.)</p>
|
||
<p class="rubric">A new tracing frontend</p>
|
||
<p>The JIT compiler now supports significantly more bytecode operations and
|
||
control flow than in Python 3.14, enabling speedups on a wider variety of
|
||
code. For example, simple Python object creation is now understood by the
|
||
3.15 JIT compiler. Overloaded operations and generators are also partially
|
||
supported. This was made possible by an overhauled JIT tracing frontend
|
||
that records actual execution paths through code, rather than estimating
|
||
them as the previous implementation did.
|
||
(Contributed by Ken Jin in <a class="reference external" href="https://github.com/python/cpython/issues/139109">gh-139109</a>. Support for Windows added by
|
||
Mark Shannon in <a class="reference external" href="https://github.com/python/cpython/issues/141703">gh-141703</a>.)</p>
|
||
<p class="rubric">Basic register allocation in the JIT</p>
|
||
<p>A basic form of register allocation has been added to the JIT compiler’s
|
||
optimizer. This allows the JIT compiler to avoid certain stack operations
|
||
altogether and instead operate on registers. This allows the JIT to produce
|
||
more efficient traces by avoiding reads and writes to memory.
|
||
(Contributed by Mark Shannon in <a class="reference external" href="https://github.com/python/cpython/issues/135379">gh-135379</a>.)</p>
|
||
<p class="rubric">More JIT optimizations</p>
|
||
<p>More <a class="reference external" href="https://en.wikipedia.org/wiki/Constant_folding">constant-propagation</a>
|
||
is now performed. This means when the JIT compiler detects that certain user
|
||
code results in constants, the code can be simplified by the JIT.
|
||
(Contributed by Ken Jin and Savannah Ostrowski in <a class="reference external" href="https://github.com/python/cpython/issues/132732">gh-132732</a>.)</p>
|
||
<p><a class="reference internal" href="../glossary.html#term-reference-count"><span class="xref std std-term">Reference counts</span></a> are avoided whenever it is safe to
|
||
do so. This generally reduces the cost of most operations in Python.
|
||
(Contributed by Ken Jin, Donghee Na, Zheao Li, Hai Zhu, Savannah Ostrowski,
|
||
Reiden Ong, Noam Cohen, Tomas Roun, PuQing, Cajetan Rodrigues, and Sacul in <a class="reference external" href="https://github.com/python/cpython/issues/134584">gh-134584</a>.)</p>
|
||
<p>By tracking unique references to objects, the JIT optimizer can now eliminate
|
||
reference count updates and perform in-place operations on ints and floats.
|
||
(Contributed by Reiden Ong, and Pieter Eendebak in <a class="reference external" href="https://github.com/python/cpython/issues/143414">gh-143414</a> and <a class="reference external" href="https://github.com/python/cpython/issues/146306">gh-146306</a>.)</p>
|
||
<p>The JIT optimizer now supports significantly more operations than in 3.14.
|
||
(Contributed by Kumar Aditya, Ken Jin, Jiahao Li, and Sacul in <a class="reference external" href="https://github.com/python/cpython/issues/131798">gh-131798</a>.)</p>
|
||
<p class="rubric">GDB and GNU <code class="docutils literal notranslate"><span class="pre">backtrace()</span></code> unwinding support</p>
|
||
<p>The JIT compiler now publishes unwind information for generated machine code to the
|
||
GDB interface on supported Linux ELF platforms. When libgcc frame
|
||
registration is available, the same unwind information is also registered for
|
||
GNU <code class="docutils literal notranslate"><span class="pre">backtrace()</span></code> stack walkers. This allows native debuggers, crash
|
||
handlers, and diagnostic tools using these mechanisms to unwind through JIT
|
||
frames instead of stopping at generated code.
|
||
(Contributed by Diego Russo and Pablo Galindo Salgado in <a class="reference external" href="https://github.com/python/cpython/issues/146071">gh-146071</a> and
|
||
<a class="reference external" href="https://github.com/python/cpython/issues/149104">gh-149104</a>.)</p>
|
||
<p class="rubric">Better machine code generation</p>
|
||
<p>The JIT compiler’s machine code generator now produces better machine code
|
||
for x86-64 and AArch64 macOS and Linux targets. In general, users should
|
||
experience lower memory usage for generated machine code and more efficient
|
||
machine code versus 3.14.
|
||
(Contributed by Brandt Bucher in <a class="reference external" href="https://github.com/python/cpython/issues/136528">gh-136528</a> and <a class="reference external" href="https://github.com/python/cpython/issues/135905">gh-135905</a>.
|
||
Implementation for AArch64 contributed by Mark Shannon in <a class="reference external" href="https://github.com/python/cpython/issues/139855">gh-139855</a>.
|
||
Additional optimizations for AArch64 contributed by Mark Shannon and
|
||
Diego Russo in <a class="reference external" href="https://github.com/python/cpython/issues/140683">gh-140683</a> and <a class="reference external" href="https://github.com/python/cpython/issues/142305">gh-142305</a>.)</p>
|
||
<p class="rubric">Maintainability</p>
|
||
<p>The JIT optimizer’s operations have been simplified.
|
||
This was made possible by a refactoring of JIT data structures.
|
||
(Contributed by Zhongtian Zheng in <a class="reference external" href="https://github.com/python/cpython/issues/148211">gh-148211</a> and Hai Zhu in <a class="reference external" href="https://github.com/python/cpython/issues/143421">gh-143421</a>.)</p>
|
||
</section>
|
||
</section>
|
||
<section id="removed">
|
||
<h2>Removed<a class="headerlink" href="#removed" title="Link to this heading">¶</a></h2>
|
||
<section id="id1">
|
||
<h3>ast<a class="headerlink" href="#id1" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The constructors of <a class="reference internal" href="../library/ast.html#ast-nodes"><span class="std std-ref">AST nodes</span></a> now raise a <a class="reference internal" href="../builtins/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>
|
||
when a required argument is omitted or when a keyword argument that does not
|
||
map to a field on the AST node is passed. These cases had previously raised a
|
||
<a class="reference internal" href="../builtins/exceptions.html#DeprecationWarning" title="DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> since Python 3.13.
|
||
(Contributed by Brian Schubert and Jelle Zijlstra in <a class="reference external" href="https://github.com/python/cpython/issues/137600">gh-137600</a> and <a class="reference external" href="https://github.com/python/cpython/issues/105858">gh-105858</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="collections-abc">
|
||
<h3>collections.abc<a class="headerlink" href="#collections-abc" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/collections.abc.html#collections.abc.ByteString" title="collections.abc.ByteString"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.ByteString</span></code></a> has been removed from
|
||
<code class="docutils literal notranslate"><span class="pre">collections.abc.__all__</span></code>. <code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.ByteString</span></code> has been
|
||
deprecated since Python 3.12, and is scheduled for removal in Python 3.17.
|
||
(Contributed by Alex Waygood in <a class="reference external" href="https://github.com/python/cpython/issues/118803">gh-118803</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id2">
|
||
<h3>ctypes<a class="headerlink" href="#id2" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed the undocumented function <code class="xref py py-func docutils literal notranslate"><span class="pre">ctypes.SetPointerType()</span></code>,
|
||
which has been deprecated since Python 3.13.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133866">gh-133866</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="datetime">
|
||
<h3>datetime<a class="headerlink" href="#datetime" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/datetime.html#datetime.datetime.strptime" title="datetime.datetime.strptime"><code class="xref py py-meth docutils literal notranslate"><span class="pre">strptime()</span></code></a> now raises <a class="reference internal" href="../builtins/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> when the
|
||
format string contains <code class="docutils literal notranslate"><span class="pre">%d</span></code> (day of month) without a year directive.
|
||
This has been deprecated since Python 3.13.
|
||
(Contributed by Stan Ulbrych and Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/70647">gh-70647</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="glob">
|
||
<h3>glob<a class="headerlink" href="#glob" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed the undocumented <code class="xref py py-func docutils literal notranslate"><span class="pre">glob.glob0()</span></code> and <code class="xref py py-func docutils literal notranslate"><span class="pre">glob.glob1()</span></code>
|
||
functions, which have been deprecated since Python 3.13. Use
|
||
<a class="reference internal" href="../library/glob.html#glob.glob" title="glob.glob"><code class="xref py py-func docutils literal notranslate"><span class="pre">glob.glob()</span></code></a> and pass a directory to its <em>root_dir</em> argument instead.
|
||
(Contributed by Barney Gale in <a class="reference external" href="https://github.com/python/cpython/issues/137466">gh-137466</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id3">
|
||
<h3>http.server<a class="headerlink" href="#id3" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed the <code class="xref py py-class docutils literal notranslate"><span class="pre">CGIHTTPRequestHandler</span></code> class
|
||
and the <code class="docutils literal notranslate"><span class="pre">--cgi</span></code> flag from the <strong class="program">python -m http.server</strong>
|
||
command-line interface. They were deprecated in Python 3.13.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133810">gh-133810</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="importlib">
|
||
<h3>importlib<a class="headerlink" href="#importlib" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">load_module()</span></code> methods of <a class="reference internal" href="../library/importlib.html#importlib.abc.Loader" title="importlib.abc.Loader"><code class="xref py py-class docutils literal notranslate"><span class="pre">Loader</span></code></a> and its
|
||
subclasses is removed.
|
||
The import system will no longer call it when defined on custom subclasses.
|
||
The method has been deprecated in favor of
|
||
<a class="reference internal" href="../library/importlib.html#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">exec_module()</span></code></a> since Python 3.4.
|
||
(Contributed by Brett Cannon in <a class="reference external" href="https://github.com/python/cpython/issues/97850">gh-97850</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="importlib-resources">
|
||
<h3>importlib.resources<a class="headerlink" href="#importlib-resources" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed deprecated <code class="docutils literal notranslate"><span class="pre">package</span></code> parameter
|
||
from <a class="reference internal" href="../library/importlib.resources.html#importlib.resources.files" title="importlib.resources.files"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.resources.files()</span></code></a> function.
|
||
(Contributed by Semyon Moroz in <a class="reference external" href="https://github.com/python/cpython/issues/138044">gh-138044</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id4">
|
||
<h3>pathlib<a class="headerlink" href="#id4" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed deprecated <code class="xref py py-meth docutils literal notranslate"><span class="pre">pathlib.PurePath.is_reserved()</span></code>.
|
||
Use <a class="reference internal" href="../library/os.path.html#os.path.isreserved" title="os.path.isreserved"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.path.isreserved()</span></code></a> to detect reserved paths on Windows.
|
||
(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/133875">gh-133875</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="platform">
|
||
<h3>platform<a class="headerlink" href="#platform" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed the <code class="xref py py-func docutils literal notranslate"><span class="pre">platform.java_ver()</span></code> function,
|
||
which was deprecated since Python 3.13.
|
||
(Contributed by Alexey Makridenko in <a class="reference external" href="https://github.com/python/cpython/issues/133604">gh-133604</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="sre">
|
||
<h3>sre_*<a class="headerlink" href="#sre" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed <code class="xref py py-mod docutils literal notranslate"><span class="pre">sre_compile</span></code>, <code class="xref py py-mod docutils literal notranslate"><span class="pre">sre_constants</span></code> and <code class="xref py py-mod docutils literal notranslate"><span class="pre">sre_parse</span></code> modules.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/135994">gh-135994</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="sysconfig">
|
||
<h3>sysconfig<a class="headerlink" href="#sysconfig" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed the <em>check_home</em> parameter of <a class="reference internal" href="../library/sysconfig.html#sysconfig.is_python_build" title="sysconfig.is_python_build"><code class="xref py py-func docutils literal notranslate"><span class="pre">sysconfig.is_python_build()</span></code></a>.
|
||
(Contributed by Filipe Laíns in <a class="reference external" href="https://github.com/python/cpython/issues/92897">gh-92897</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id5">
|
||
<h3>threading<a class="headerlink" href="#id5" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Remove support for arbitrary positional or keyword arguments in the C
|
||
implementation of <a class="reference internal" href="../library/threading.html#threading.RLock" title="threading.RLock"><code class="xref py py-class docutils literal notranslate"><span class="pre">RLock</span></code></a> objects. This was deprecated
|
||
in Python 3.14.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/134087">gh-134087</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id6">
|
||
<h3>types<a class="headerlink" href="#id6" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed <code class="xref py py-attr docutils literal notranslate"><span class="pre">codeobject.co_lnotab</span></code> from <a class="reference internal" href="../library/types.html#types.CodeType" title="types.CodeType"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.CodeType</span></code></a>,
|
||
deprecated since Python 3.12 by <span class="target" id="index-56"></span><a class="pep reference external" href="https://peps.python.org/pep-0626/"><strong>PEP 626</strong></a>.
|
||
(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/134690">gh-134690</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id7">
|
||
<h3>typing<a class="headerlink" href="#id7" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/typing.html#typing.ByteString" title="typing.ByteString"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.ByteString</span></code></a> has been removed from <code class="docutils literal notranslate"><span class="pre">typing.__all__</span></code>.
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">typing.ByteString</span></code> has been deprecated since Python 3.9, and is
|
||
scheduled for removal in Python 3.17.
|
||
(Contributed by Alex Waygood in <a class="reference external" href="https://github.com/python/cpython/issues/118803">gh-118803</a>.)</p></li>
|
||
<li><p>The undocumented keyword argument syntax for creating
|
||
<a class="reference internal" href="../library/typing.html#typing.NamedTuple" title="typing.NamedTuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">NamedTuple</span></code></a> classes (for example,
|
||
<code class="docutils literal notranslate"><span class="pre">Point</span> <span class="pre">=</span> <span class="pre">NamedTuple("Point",</span> <span class="pre">x=int,</span> <span class="pre">y=int)</span></code>) is no longer supported.
|
||
Use the class-based syntax or the functional syntax instead.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133817">gh-133817</a>.)</p></li>
|
||
<li><p>Using <code class="docutils literal notranslate"><span class="pre">TD</span> <span class="pre">=</span> <span class="pre">TypedDict("TD")</span></code> or <code class="docutils literal notranslate"><span class="pre">TD</span> <span class="pre">=</span> <span class="pre">TypedDict("TD",</span> <span class="pre">None)</span></code> to
|
||
construct a <a class="reference internal" href="../library/typing.html#typing.TypedDict" title="typing.TypedDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypedDict</span></code></a> type with zero fields is no
|
||
longer supported. Use <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">TD(TypedDict):</span> <span class="pre">pass</span></code>
|
||
or <code class="docutils literal notranslate"><span class="pre">TD</span> <span class="pre">=</span> <span class="pre">TypedDict("TD",</span> <span class="pre">{})</span></code> instead.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133823">gh-133823</a>.)</p></li>
|
||
<li><p>Deprecated <code class="xref py py-deco docutils literal notranslate"><span class="pre">@typing.no_type_check_decorator</span></code> has been removed.
|
||
(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/133601">gh-133601</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="id8">
|
||
<h3>wave<a class="headerlink" href="#id8" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Removed the <code class="docutils literal notranslate"><span class="pre">getmark()</span></code>, <code class="docutils literal notranslate"><span class="pre">setmark()</span></code> and <code class="docutils literal notranslate"><span class="pre">getmarkers()</span></code> methods
|
||
of the <a class="reference internal" href="../library/wave.html#wave.Wave_read" title="wave.Wave_read"><code class="xref py py-class docutils literal notranslate"><span class="pre">Wave_read</span></code></a> and <a class="reference internal" href="../library/wave.html#wave.Wave_write" title="wave.Wave_write"><code class="xref py py-class docutils literal notranslate"><span class="pre">Wave_write</span></code></a> classes,
|
||
which were deprecated since Python 3.13.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133873">gh-133873</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="zipimport">
|
||
<h3>zipimport<a class="headerlink" href="#zipimport" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>Remove deprecated <code class="xref py py-meth docutils literal notranslate"><span class="pre">zipimport.zipimporter.load_module()</span></code>.
|
||
Use <a class="reference internal" href="../library/zipimport.html#zipimport.zipimporter.exec_module" title="zipimport.zipimporter.exec_module"><code class="xref py py-meth docutils literal notranslate"><span class="pre">zipimport.zipimporter.exec_module()</span></code></a> instead.
|
||
(Contributed by Jiahao Li in <a class="reference external" href="https://github.com/python/cpython/issues/133656">gh-133656</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
<section id="deprecated">
|
||
<h2>Deprecated<a class="headerlink" href="#deprecated" title="Link to this heading">¶</a></h2>
|
||
<section id="new-deprecations">
|
||
<h3>New deprecations<a class="headerlink" href="#new-deprecations" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/ast.html#module-ast" title="ast: Abstract Syntax Tree classes and manipulation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ast</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>Creating instances of abstract AST nodes (such as <a class="reference internal" href="../library/ast.html#ast.AST" title="ast.AST"><code class="xref py py-class docutils literal notranslate"><span class="pre">ast.AST</span></code></a>
|
||
or <code class="xref py py-class docutils literal notranslate"><span class="pre">ast.expr</span></code>) is deprecated and will raise an error in Python 3.20.</p>
|
||
<p>(Contributed by Brian Schubert in <a class="reference external" href="https://github.com/python/cpython/issues/116021">gh-116021</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/base64.html#module-base64" title="base64: RFC 4648: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85"><code class="xref py py-mod docutils literal notranslate"><span class="pre">base64</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Accepting the <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">/</span></code> characters with an alternative alphabet in
|
||
<a class="reference internal" href="../library/base64.html#base64.b64decode" title="base64.b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b64decode()</span></code></a> and <a class="reference internal" href="../library/base64.html#base64.urlsafe_b64decode" title="base64.urlsafe_b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlsafe_b64decode()</span></code></a> is now
|
||
deprecated.
|
||
In future Python versions they will be errors in the strict mode and
|
||
discarded in the non-strict mode.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/125346">gh-125346</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p>CLI:</p>
|
||
<ul>
|
||
<li><p>Deprecate <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> and <code class="xref std std-option docutils literal notranslate"><span class="pre">-bb</span></code> command-line options
|
||
and schedule them to become no-ops in Python 3.17.
|
||
These were primarily helpers for the Python 2 -> 3 transition.
|
||
Starting with Python 3.17, no <a class="reference internal" href="../builtins/exceptions.html#BytesWarning" title="BytesWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BytesWarning</span></code></a> will be raised
|
||
for these cases; use a type checker instead.</p>
|
||
<p>(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/136355">gh-136355</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/collections.abc.html#module-collections.abc" title="collections.abc: Abstract base classes for containers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections.abc</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>The following statements now cause <code class="docutils literal notranslate"><span class="pre">DeprecationWarning</span></code>s to be emitted
|
||
at runtime:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">collections.abc</span> <span class="pre">import</span> <span class="pre">ByteString</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">collections.abc;</span> <span class="pre">collections.abc.ByteString</span></code>.</p></li>
|
||
</ul>
|
||
<p><code class="docutils literal notranslate"><span class="pre">DeprecationWarning</span></code>s were already emitted if
|
||
<a class="reference internal" href="../library/collections.abc.html#collections.abc.ByteString" title="collections.abc.ByteString"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.ByteString</span></code></a> was subclassed or used as the second
|
||
argument to <a class="reference internal" href="../builtins/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a> or <a class="reference internal" href="../builtins/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a>, but warnings were not
|
||
previously emitted if it was merely imported or accessed from the
|
||
<code class="xref py py-mod docutils literal notranslate"><span class="pre">collections.abc</span></code> module.
|
||
(Contributed by Alex Waygood in <a class="reference external" href="https://github.com/python/cpython/issues/118803">gh-118803</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>In hash function constructors such as <a class="reference internal" href="../library/hashlib.html#hashlib.new" title="hashlib.new"><code class="xref py py-func docutils literal notranslate"><span class="pre">new()</span></code></a> or the
|
||
direct hash-named constructors such as <a class="reference internal" href="../library/hashlib.html#hashlib.md5" title="hashlib.md5"><code class="xref py py-func docutils literal notranslate"><span class="pre">md5()</span></code></a> and
|
||
<a class="reference internal" href="../library/hashlib.html#hashlib.sha256" title="hashlib.sha256"><code class="xref py py-func docutils literal notranslate"><span class="pre">sha256()</span></code></a>, the optional initial data parameter could
|
||
also be passed as a keyword argument named <code class="docutils literal notranslate"><span class="pre">data=</span></code> or <code class="docutils literal notranslate"><span class="pre">string=</span></code> in
|
||
various <a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a> implementations.</p>
|
||
<p>Support for the <code class="docutils literal notranslate"><span class="pre">string</span></code> keyword argument name is now deprecated and
|
||
is slated for removal in Python 3.19. Prefer passing the initial data as
|
||
a positional argument for maximum backwards compatibility.</p>
|
||
<p>(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/134978">gh-134978</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/http.cookies.html#module-http.cookies" title="http.cookies: Support for HTTP state management (cookies)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.cookies</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.js_output" title="http.cookies.Morsel.js_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Morsel.js_output</span></code></a> and
|
||
<a class="reference internal" href="../library/http.cookies.html#http.cookies.BaseCookie.js_output" title="http.cookies.BaseCookie.js_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseCookie.js_output</span></code></a> are
|
||
deprecated and will be removed in Python 3.19. Use
|
||
<a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.output" title="http.cookies.Morsel.output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Morsel.output</span></code></a> or
|
||
<a class="reference internal" href="../library/http.cookies.html#http.cookies.BaseCookie.output" title="http.cookies.BaseCookie.output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseCookie.output</span></code></a> instead.
|
||
(Contributed by kishorhange111 in <a class="reference external" href="https://github.com/python/cpython/issues/148849">gh-148849</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/imaplib.html#module-imaplib" title="imaplib: IMAP4 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">imaplib</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Altering <a class="reference internal" href="../library/imaplib.html#imaplib.IMAP4.file" title="imaplib.IMAP4.file"><code class="xref py py-attr docutils literal notranslate"><span class="pre">IMAP4.file</span></code></a> is now deprecated
|
||
and slated for removal in Python 3.19. This property is now unused
|
||
and changing its value does <em>not</em> explicitly close the current file.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/142307">gh-142307</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/profile.html#module-profile" title="profile: Pure Python profiler (deprecated). (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code> module is deprecated and will be removed in
|
||
Python 3.17. Use <a class="reference internal" href="../library/profiling.tracing.html#module-profiling.tracing" title="profiling.tracing: Deterministic tracing profiler for Python programs."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.tracing</span></code></a> instead, which provides a
|
||
compatible API. See <span class="target" id="index-57"></span><a class="pep reference external" href="https://peps.python.org/pep-0799/"><strong>PEP 799</strong></a> for details.
|
||
(Contributed by Pablo Galindo and László Kiss Kollár in <a class="reference external" href="https://github.com/python/cpython/issues/138122">gh-138122</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">re</span></code></a>:</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/re.html#re.match" title="re.match"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.match()</span></code></a> and <a class="reference internal" href="../library/re.html#re.Pattern.match" title="re.Pattern.match"><code class="xref py py-meth docutils literal notranslate"><span class="pre">re.Pattern.match()</span></code></a> are now
|
||
<a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a> in favor of the new <a class="reference internal" href="../library/re.html#re.prefixmatch" title="re.prefixmatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.prefixmatch()</span></code></a> and
|
||
<a class="reference internal" href="../library/re.html#re.Pattern.prefixmatch" title="re.Pattern.prefixmatch"><code class="xref py py-meth docutils literal notranslate"><span class="pre">re.Pattern.prefixmatch()</span></code></a> APIs, which have been added as alternate,
|
||
more explicit names. These are intended to be used to alleviate confusion
|
||
around what <em>match</em> means by following the Zen of Python’s <em>“Explicit is
|
||
better than implicit”</em> mantra. Most other language regular expression
|
||
libraries use an API named <em>match</em> to mean what Python has always called
|
||
<em>search</em>.</p>
|
||
<p>We <strong>do not</strong> plan to remove the older <code class="xref py py-func docutils literal notranslate"><span class="pre">match()</span></code> name, as it has been
|
||
used in code for over 30 years. Code supporting older versions of Python
|
||
should continue to use <code class="xref py py-func docutils literal notranslate"><span class="pre">match()</span></code>, while new code should prefer
|
||
<code class="xref py py-func docutils literal notranslate"><span class="pre">prefixmatch()</span></code>. See <a class="reference internal" href="../library/re.html#prefixmatch-vs-match"><span class="std std-ref">prefixmatch() vs. match()</span></a>.</p>
|
||
<p>(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/86519">gh-86519</a> and
|
||
Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/148100">gh-148100</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/struct.html#module-struct" title="struct: Interpret bytes as packed binary data."><code class="xref py py-mod docutils literal notranslate"><span class="pre">struct</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>Calling <code class="docutils literal notranslate"><span class="pre">Struct.__new__()</span></code> without a required argument is now
|
||
deprecated and will be removed in Python 3.20. Calling the
|
||
<a class="reference internal" href="../reference/datamodel.html#object.__init__" title="object.__init__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__init__()</span></code></a> method on an initialized <a class="reference internal" href="../library/struct.html#struct.Struct" title="struct.Struct"><code class="xref py py-class docutils literal notranslate"><span class="pre">Struct</span></code></a>
|
||
object is deprecated and will be removed in Python 3.20.</p>
|
||
<p>(Contributed by Sergey B Kirpichev and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143715">gh-143715</a>.)</p>
|
||
</li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">'F'</span></code> and <code class="docutils literal notranslate"><span class="pre">'D'</span></code> type codes are now <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>
|
||
in favor of the two-letter forms <code class="docutils literal notranslate"><span class="pre">'Zf'</span></code> and <code class="docutils literal notranslate"><span class="pre">'Zd'</span></code>.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/121249">gh-121249</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>The following statements now cause <code class="docutils literal notranslate"><span class="pre">DeprecationWarning</span></code>s to be emitted
|
||
at runtime:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">typing</span> <span class="pre">import</span> <span class="pre">ByteString</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">typing;</span> <span class="pre">typing.ByteString</span></code>.</p></li>
|
||
</ul>
|
||
<p><code class="docutils literal notranslate"><span class="pre">DeprecationWarning</span></code>s were already emitted if <a class="reference internal" href="../library/typing.html#typing.ByteString" title="typing.ByteString"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.ByteString</span></code></a>
|
||
was subclassed or used as the second argument to <a class="reference internal" href="../builtins/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a> or
|
||
<a class="reference internal" href="../builtins/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a>, but warnings were not previously emitted if it was
|
||
merely imported or accessed from the <code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code> module.
|
||
(Contributed by Alex Waygood in <a class="reference external" href="https://github.com/python/cpython/issues/118803">gh-118803</a>.)</p>
|
||
</li>
|
||
<li><p>It is deprecated to call <a class="reference internal" href="../builtins/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a> and <a class="reference internal" href="../builtins/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a> checks on
|
||
protocol classes that were not explicitly decorated with <code class="xref py py-func docutils literal notranslate"><span class="pre">runtime_checkable()</span></code>
|
||
but that inherit from a runtime-checkable protocol class.
|
||
This will raise a <a class="reference internal" href="../builtins/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> in Python 3.20.</p>
|
||
<p>(Contributed by Bartosz Sławecki in <a class="reference external" href="https://github.com/python/cpython/issues/132604">gh-132604</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/webbrowser.html#module-webbrowser" title="webbrowser: Easy-to-use controller for web browsers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">webbrowser</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">webbrowser.MacOSXOSAScript</span></code> is deprecated in favour of
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">webbrowser.MacOS</span></code> and scheduled for removal in Python 3.17.
|
||
(Contributed by Jeff Lyon in <a class="reference external" href="https://github.com/python/cpython/issues/137586">gh-137586</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">__version__</span></code>:</p>
|
||
<ul>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">__version__</span></code>, <code class="docutils literal notranslate"><span class="pre">version</span></code> and <code class="docutils literal notranslate"><span class="pre">VERSION</span></code> attributes have been
|
||
deprecated in these standard library modules and will be removed in
|
||
Python 3.20. Use <a class="reference internal" href="../library/sys.html#sys.version_info" title="sys.version_info"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.version_info</span></code></a> instead.</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/argparse.html#module-argparse" title="argparse: Command-line option and argument parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">argparse</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/csv.html#module-csv" title="csv: Write and read tabular data to and from delimited files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">csv</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/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></p></li>
|
||
<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">ctypes.macholib</span></code></p></li>
|
||
<li><p><a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a> (use <a class="reference internal" href="../library/decimal.html#decimal.SPEC_VERSION" title="decimal.SPEC_VERSION"><code class="xref py py-data docutils literal notranslate"><span class="pre">decimal.SPEC_VERSION</span></code></a> instead)</p></li>
|
||
<li><p><a class="reference internal" href="../library/http.server.html#module-http.server" title="http.server: HTTP server and request handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.server</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/imaplib.html#module-imaplib" title="imaplib: IMAP4 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">imaplib</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/ipaddress.html#module-ipaddress" title="ipaddress: IPv4/IPv6 manipulation library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ipaddress</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/json.html#module-json" title="json: Encode and decode the JSON format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/logging.html#module-logging" title="logging: Flexible event logging system for applications."><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code></a> (<code class="docutils literal notranslate"><span class="pre">__date__</span></code> also deprecated)</p></li>
|
||
<li><p><a class="reference internal" href="../library/optparse.html#module-optparse" title="optparse: Command-line option parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">optparse</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/platform.html#module-platform" title="platform: Retrieves as much platform identifying data as possible."><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">re</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/socketserver.html#module-socketserver" title="socketserver: A framework for network servers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socketserver</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tabnanny.html#module-tabnanny" title="tabnanny: Tool for detecting white space related problems in Python source files in a directory tree."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tabnanny</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#module-tarfile" title="tarfile: Read and write tar-format archive files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tarfile</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tkinter.font.html#module-tkinter.font" title="tkinter.font: Tkinter font-wrapping class"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.font</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tkinter.ttk.html#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/wsgiref.html#module-wsgiref.simple_server" title="wsgiref.simple_server: A simple WSGI HTTP server."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref.simple_server</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code></a></p></li>
|
||
<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.expatreader</span></code></p></li>
|
||
<li><p><a class="reference internal" href="../library/xml.sax.handler.html#module-xml.sax.handler" title="xml.sax.handler: Base classes for SAX event handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.handler</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a></p></li>
|
||
</ul>
|
||
<p>(Contributed by Hugo van Kemenade and Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/76007">gh-76007</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="pending-removal-in-python-3-16">
|
||
<h3>Pending removal in Python 3.16<a class="headerlink" href="#pending-removal-in-python-3-16" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>The import system:</p>
|
||
<ul class="simple">
|
||
<li><p>Setting <a class="reference internal" href="../reference/datamodel.html#module.__loader__" title="module.__loader__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__loader__</span></code></a> on a module while
|
||
failing to set <a class="reference internal" href="../library/importlib.html#importlib.machinery.ModuleSpec.loader" title="importlib.machinery.ModuleSpec.loader"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__spec__.loader</span></code></a>
|
||
is deprecated. In Python 3.16, <code class="xref py py-attr docutils literal notranslate"><span class="pre">__loader__</span></code> will cease to be set or
|
||
taken into consideration by the import system or the standard library.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/array.html#module-array" title="array: Space efficient arrays of uniformly typed numeric values."><code class="xref py py-mod docutils literal notranslate"><span class="pre">array</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">'u'</span></code> format code (<code class="xref c c-type docutils literal notranslate"><span class="pre">wchar_t</span></code>)
|
||
has been deprecated in documentation since Python 3.3
|
||
and at runtime since Python 3.13.
|
||
Use the <code class="docutils literal notranslate"><span class="pre">'w'</span></code> format code (<a class="reference internal" href="../c-api/unicode.html#c.Py_UCS4" title="Py_UCS4"><code class="xref c c-type docutils literal notranslate"><span class="pre">Py_UCS4</span></code></a>)
|
||
for Unicode characters instead.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a>:</p>
|
||
<ul>
|
||
<li><p><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.iscoroutinefunction()</span></code> is deprecated
|
||
and will be removed in Python 3.16;
|
||
use <a class="reference internal" href="../library/inspect.html#inspect.iscoroutinefunction" title="inspect.iscoroutinefunction"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.iscoroutinefunction()</span></code></a> instead.
|
||
(Contributed by Jiahao Li and Kumar Aditya in <a class="reference external" href="https://github.com/python/cpython/issues/122875">gh-122875</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio.html#module-asyncio" title="asyncio: Asynchronous I/O."><code class="xref py py-mod docutils literal notranslate"><span class="pre">asyncio</span></code></a> policy system is deprecated and will be removed in Python 3.16.
|
||
In particular, the following classes and functions are deprecated:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/asyncio-policy.html#asyncio.AbstractEventLoopPolicy" title="asyncio.AbstractEventLoopPolicy"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.AbstractEventLoopPolicy</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio-policy.html#asyncio.DefaultEventLoopPolicy" title="asyncio.DefaultEventLoopPolicy"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.DefaultEventLoopPolicy</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio-policy.html#asyncio.WindowsSelectorEventLoopPolicy" title="asyncio.WindowsSelectorEventLoopPolicy"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.WindowsSelectorEventLoopPolicy</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio-policy.html#asyncio.WindowsProactorEventLoopPolicy" title="asyncio.WindowsProactorEventLoopPolicy"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.WindowsProactorEventLoopPolicy</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio-policy.html#asyncio.get_event_loop_policy" title="asyncio.get_event_loop_policy"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.get_event_loop_policy()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/asyncio-policy.html#asyncio.set_event_loop_policy" title="asyncio.set_event_loop_policy"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.set_event_loop_policy()</span></code></a></p></li>
|
||
</ul>
|
||
<p>Users should use <a class="reference internal" href="../library/asyncio-runner.html#asyncio.run" title="asyncio.run"><code class="xref py py-func docutils literal notranslate"><span class="pre">asyncio.run()</span></code></a> or <a class="reference internal" href="../library/asyncio-runner.html#asyncio.Runner" title="asyncio.Runner"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.Runner</span></code></a> with
|
||
<em>loop_factory</em> to use the desired event loop implementation.</p>
|
||
<p>For example, to use <a class="reference internal" href="../library/asyncio-eventloop.html#asyncio.SelectorEventLoop" title="asyncio.SelectorEventLoop"><code class="xref py py-class docutils literal notranslate"><span class="pre">asyncio.SelectorEventLoop</span></code></a> on Windows:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">asyncio</span>
|
||
|
||
<span class="k">async</span> <span class="k">def</span><span class="w"> </span><span class="nf">main</span><span class="p">():</span>
|
||
<span class="o">...</span>
|
||
|
||
<span class="n">asyncio</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">main</span><span class="p">(),</span> <span class="n">loop_factory</span><span class="o">=</span><span class="n">asyncio</span><span class="o">.</span><span class="n">SelectorEventLoop</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>(Contributed by Kumar Aditya in <a class="reference external" href="https://github.com/python/cpython/issues/127949">gh-127949</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Bitwise inversion on boolean types, <code class="docutils literal notranslate"><span class="pre">~True</span></code> or <code class="docutils literal notranslate"><span class="pre">~False</span></code>
|
||
has been deprecated since Python 3.12,
|
||
as it produces surprising and unintuitive results (<code class="docutils literal notranslate"><span class="pre">-2</span></code> and <code class="docutils literal notranslate"><span class="pre">-1</span></code>).
|
||
Use <code class="docutils literal notranslate"><span class="pre">not</span> <span class="pre">x</span></code> instead for the logical negation of a Boolean.
|
||
In the rare case that you need the bitwise inversion of
|
||
the underlying integer, convert to <code class="docutils literal notranslate"><span class="pre">int</span></code> explicitly (<code class="docutils literal notranslate"><span class="pre">~int(x)</span></code>).</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/functools.html#module-functools" title="functools: Higher-order functions and operations on callable objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">functools</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Calling the Python implementation of <a class="reference internal" href="../library/functools.html#functools.reduce" title="functools.reduce"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.reduce()</span></code></a> with <em>function</em>
|
||
or <em>sequence</em> as keyword arguments has been deprecated since Python 3.14.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/logging.html#module-logging" title="logging: Flexible event logging system for applications."><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Support for custom logging handlers with the <em>strm</em> argument is deprecated
|
||
and scheduled for removal in Python 3.16. Define handlers with the <em>stream</em>
|
||
argument instead. (Contributed by Mariusz Felisiak in <a class="reference external" href="https://github.com/python/cpython/issues/115032">gh-115032</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/mimetypes.html#module-mimetypes" title="mimetypes: Mapping of filename extensions to MIME types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">mimetypes</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Valid extensions start with a ‘.’ or are empty for
|
||
<a class="reference internal" href="../library/mimetypes.html#mimetypes.MimeTypes.add_type" title="mimetypes.MimeTypes.add_type"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mimetypes.MimeTypes.add_type()</span></code></a>.
|
||
Undotted extensions are deprecated and will
|
||
raise a <a class="reference internal" href="../builtins/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> in Python 3.16.
|
||
(Contributed by Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/75223">gh-75223</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/shutil.html#module-shutil" title="shutil: High-level file operations, including copying."><code class="xref py py-mod docutils literal notranslate"><span class="pre">shutil</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">ExecError</span></code> exception
|
||
has been deprecated since Python 3.14.
|
||
It has not been used by any function in <code class="xref py py-mod docutils literal notranslate"><span class="pre">shutil</span></code> since Python 3.4,
|
||
and is now an alias of <a class="reference internal" href="../builtins/exceptions.html#RuntimeError" title="RuntimeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a>.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/symtable.html#module-symtable" title="symtable: Interface to the compiler's internal symbol tables."><code class="xref py py-mod docutils literal notranslate"><span class="pre">symtable</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/symtable.html#symtable.Class.get_methods" title="symtable.Class.get_methods"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Class.get_methods</span></code></a> method
|
||
has been deprecated since Python 3.14.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../library/sys.html#sys._enablelegacywindowsfsencoding" title="sys._enablelegacywindowsfsencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">_enablelegacywindowsfsencoding()</span></code></a> function
|
||
has been deprecated since Python 3.13.
|
||
Use the <span class="target" id="index-58"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONLEGACYWINDOWSFSENCODING"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONLEGACYWINDOWSFSENCODING</span></code></a> environment variable instead.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/sysconfig.html#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <code class="xref py py-func docutils literal notranslate"><span class="pre">sysconfig.expand_makefile_vars()</span></code> function
|
||
has been deprecated since Python 3.14.
|
||
Use the <code class="docutils literal notranslate"><span class="pre">vars</span></code> argument of <a class="reference internal" href="../library/sysconfig.html#sysconfig.get_paths" title="sysconfig.get_paths"><code class="xref py py-func docutils literal notranslate"><span class="pre">sysconfig.get_paths()</span></code></a> instead.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#module-tarfile" title="tarfile: Read and write tar-format archive files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tarfile</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The undocumented and unused <code class="xref py py-attr docutils literal notranslate"><span class="pre">TarFile.tarfile</span></code> attribute
|
||
has been deprecated since Python 3.13.</p></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="pending-removal-in-python-3-17">
|
||
<h3>Pending removal in Python 3.17<a class="headerlink" href="#pending-removal-in-python-3-17" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/datetime.html#datetime.datetime.strptime" title="datetime.datetime.strptime"><code class="xref py py-meth docutils literal notranslate"><span class="pre">strptime()</span></code></a> calls using a format string containing
|
||
<code class="docutils literal notranslate"><span class="pre">%e</span></code> (day of month) without a year.
|
||
This has been deprecated since Python 3.15.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/70647">gh-70647</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/collections.abc.html#module-collections.abc" title="collections.abc: Abstract base classes for containers"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections.abc</span></code></a>:</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/collections.abc.html#collections.abc.ByteString" title="collections.abc.ByteString"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.abc.ByteString</span></code></a> is scheduled for removal in Python 3.17.</p>
|
||
<p>Use <code class="docutils literal notranslate"><span class="pre">isinstance(obj,</span> <span class="pre">collections.abc.Buffer)</span></code> to test if <code class="docutils literal notranslate"><span class="pre">obj</span></code>
|
||
implements the <a class="reference internal" href="../c-api/buffer.html#bufferobjects"><span class="std std-ref">buffer protocol</span></a> at runtime. For use
|
||
in type annotations, either use <a class="reference internal" href="../library/collections.abc.html#collections.abc.Buffer" title="collections.abc.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a> or a union
|
||
that explicitly specifies the types your code supports (e.g.,
|
||
<code class="docutils literal notranslate"><span class="pre">bytes</span> <span class="pre">|</span> <span class="pre">bytearray</span> <span class="pre">|</span> <span class="pre">memoryview</span></code>).</p>
|
||
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">ByteString</span></code> was originally intended to be an abstract class that
|
||
would serve as a supertype of both <a class="reference internal" href="../builtins/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and <a class="reference internal" href="../builtins/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>.
|
||
However, since the ABC never had any methods, knowing that an object was an
|
||
instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">ByteString</span></code> never actually told you anything useful
|
||
about the object. Other common buffer types such as <a class="reference internal" href="../builtins/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a>
|
||
were also never understood as subtypes of <code class="xref py py-class docutils literal notranslate"><span class="pre">ByteString</span></code> (either at
|
||
runtime or by static type checkers).</p>
|
||
<p>See <span class="target" id="index-59"></span><a class="pep reference external" href="https://peps.python.org/pep-0688/#current-options"><strong>PEP 688</strong></a> for more details.
|
||
(Contributed by Shantanu Jain in <a class="reference external" href="https://github.com/python/cpython/issues/91896">gh-91896</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/codecs.html#module-encodings" title="encodings: Encodings package"><code class="xref py py-mod docutils literal notranslate"><span class="pre">encodings</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Passing non-ascii <em>encoding</em> names to <a class="reference internal" href="../library/codecs.html#encodings.normalize_encoding" title="encodings.normalize_encoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">encodings.normalize_encoding()</span></code></a>
|
||
is deprecated and scheduled for removal in Python 3.17.
|
||
(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/136702">gh-136702</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/profile.html#module-profile" title="profile: Pure Python profiler (deprecated). (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">profile</span></code> module is deprecated and will be removed in
|
||
Python 3.17. Use <a class="reference internal" href="../library/profiling.tracing.html#module-profiling.tracing" title="profiling.tracing: Deterministic tracing profiler for Python programs."><code class="xref py py-mod docutils literal notranslate"><span class="pre">profiling.tracing</span></code></a> instead, which provides a
|
||
compatible API. See <span class="target" id="index-60"></span><a class="pep reference external" href="https://peps.python.org/pep-0799/"><strong>PEP 799</strong></a> for details.
|
||
(Contributed by Pablo Galindo and László Kiss Kollár in <a class="reference external" href="https://github.com/python/cpython/issues/138122">gh-138122</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/webbrowser.html#module-webbrowser" title="webbrowser: Easy-to-use controller for web browsers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">webbrowser</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">webbrowser.MacOSXOSAScript</span></code> is deprecated in favour of
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">webbrowser.MacOS</span></code>. (<a class="reference external" href="https://github.com/python/cpython/issues/137586">gh-137586</a>)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>Before Python 3.14, old-style unions were implemented using the private class
|
||
<code class="docutils literal notranslate"><span class="pre">typing._UnionGenericAlias</span></code>. This class is no longer needed for the implementation,
|
||
but it has been retained for backward compatibility, with removal scheduled for Python
|
||
3.17. Users should use documented introspection helpers like <a class="reference internal" href="../library/typing.html#typing.get_origin" title="typing.get_origin"><code class="xref py py-func docutils literal notranslate"><span class="pre">typing.get_origin()</span></code></a>
|
||
and <a class="reference internal" href="../library/typing.html#typing.get_args" title="typing.get_args"><code class="xref py py-func docutils literal notranslate"><span class="pre">typing.get_args()</span></code></a> instead of relying on private implementation details.</p></li>
|
||
<li><p><a class="reference internal" href="../library/typing.html#typing.ByteString" title="typing.ByteString"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.ByteString</span></code></a>, deprecated since Python 3.9, is scheduled for removal in
|
||
Python 3.17.</p>
|
||
<p>Use <code class="docutils literal notranslate"><span class="pre">isinstance(obj,</span> <span class="pre">collections.abc.Buffer)</span></code> to test if <code class="docutils literal notranslate"><span class="pre">obj</span></code>
|
||
implements the <a class="reference internal" href="../c-api/buffer.html#bufferobjects"><span class="std std-ref">buffer protocol</span></a> at runtime. For use
|
||
in type annotations, either use <a class="reference internal" href="../library/collections.abc.html#collections.abc.Buffer" title="collections.abc.Buffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Buffer</span></code></a> or a union
|
||
that explicitly specifies the types your code supports (e.g.,
|
||
<code class="docutils literal notranslate"><span class="pre">bytes</span> <span class="pre">|</span> <span class="pre">bytearray</span> <span class="pre">|</span> <span class="pre">memoryview</span></code>).</p>
|
||
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">ByteString</span></code> was originally intended to be an abstract class that
|
||
would serve as a supertype of both <a class="reference internal" href="../builtins/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and <a class="reference internal" href="../builtins/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>.
|
||
However, since the ABC never had any methods, knowing that an object was an
|
||
instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">ByteString</span></code> never actually told you anything useful
|
||
about the object. Other common buffer types such as <a class="reference internal" href="../builtins/stdtypes.html#memoryview" title="memoryview"><code class="xref py py-class docutils literal notranslate"><span class="pre">memoryview</span></code></a>
|
||
were also never understood as subtypes of <code class="xref py py-class docutils literal notranslate"><span class="pre">ByteString</span></code> (either at
|
||
runtime or by static type checkers).</p>
|
||
<p>See <span class="target" id="index-61"></span><a class="pep reference external" href="https://peps.python.org/pep-0688/#current-options"><strong>PEP 688</strong></a> for more details.
|
||
(Contributed by Shantanu Jain in <a class="reference external" href="https://github.com/python/cpython/issues/91896">gh-91896</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/tkinter.html#module-tkinter" title="tkinter: Interface to Tcl/Tk for graphical user interfaces"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The <code class="xref py py-class docutils literal notranslate"><span class="pre">tkinter.Variable</span></code> methods <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_variable()</span></code>,
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">trace()</span></code> (an alias of <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_variable()</span></code>),
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_vdelete()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_vinfo()</span></code>, deprecated since
|
||
Python 3.14, are scheduled for removal in Python 3.17.
|
||
Use <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_add()</span></code>, <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_remove()</span></code> and <code class="xref py py-meth docutils literal notranslate"><span class="pre">trace_info()</span></code>
|
||
instead.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/120220">gh-120220</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="pending-removal-in-python-3-18">
|
||
<h3>Pending removal in Python 3.18<a class="headerlink" href="#pending-removal-in-python-3-18" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>No longer accept a boolean value when a file descriptor is expected.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/82626">gh-82626</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>The non-standard and undocumented <a class="reference internal" href="../library/decimal.html#decimal.Decimal" title="decimal.Decimal"><code class="xref py py-class docutils literal notranslate"><span class="pre">Decimal</span></code></a> format
|
||
specifier <code class="docutils literal notranslate"><span class="pre">'N'</span></code>, which is only supported in the <code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code> module’s
|
||
C implementation, has been deprecated since Python 3.13.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/89902">gh-89902</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p>Deprecations defined by <span class="target" id="index-62"></span><a class="pep reference external" href="https://peps.python.org/pep-0829/"><strong>PEP 829</strong></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">import</span></code> lines in <code class="file docutils literal notranslate"><em><span class="pre">name</span></em><span class="pre">.pth</span></code> files are silently ignored.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Barry Warsaw in <a class="reference external" href="https://github.com/python/cpython/issues/148641">gh-148641</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="pending-removal-in-python-3-19">
|
||
<h3>Pending removal in Python 3.19<a class="headerlink" href="#pending-removal-in-python-3-19" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/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>:</p>
|
||
<ul class="simple">
|
||
<li><p>Implicitly switching to the MSVC-compatible struct layout by setting
|
||
<a class="reference internal" href="../library/ctypes.html#ctypes.Structure._pack_" title="ctypes.Structure._pack_"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_pack_</span></code></a> but not <a class="reference internal" href="../library/ctypes.html#ctypes.Structure._layout_" title="ctypes.Structure._layout_"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_layout_</span></code></a>
|
||
on non-Windows platforms.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/hashlib.html#module-hashlib" title="hashlib: Secure hash and message digest algorithms."><code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>In hash function constructors such as <a class="reference internal" href="../library/hashlib.html#hashlib.new" title="hashlib.new"><code class="xref py py-func docutils literal notranslate"><span class="pre">new()</span></code></a> or the
|
||
direct hash-named constructors such as <a class="reference internal" href="../library/hashlib.html#hashlib.md5" title="hashlib.md5"><code class="xref py py-func docutils literal notranslate"><span class="pre">md5()</span></code></a> and
|
||
<a class="reference internal" href="../library/hashlib.html#hashlib.sha256" title="hashlib.sha256"><code class="xref py py-func docutils literal notranslate"><span class="pre">sha256()</span></code></a>, their optional initial data parameter could
|
||
also be passed a keyword argument named <code class="docutils literal notranslate"><span class="pre">data=</span></code> or <code class="docutils literal notranslate"><span class="pre">string=</span></code> in
|
||
various <code class="xref py py-mod docutils literal notranslate"><span class="pre">hashlib</span></code> implementations.</p>
|
||
<p>Support for the <code class="docutils literal notranslate"><span class="pre">string</span></code> keyword argument name is now deprecated
|
||
and slated for removal in Python 3.19.</p>
|
||
<p>Before Python 3.13, the <code class="docutils literal notranslate"><span class="pre">string</span></code> keyword parameter was not correctly
|
||
supported depending on the backend implementation of hash functions.
|
||
Prefer passing the initial data as a positional argument for maximum
|
||
backwards compatibility.</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/http.cookies.html#module-http.cookies" title="http.cookies: Support for HTTP state management (cookies)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.cookies</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/http.cookies.html#http.cookies.Morsel.js_output" title="http.cookies.Morsel.js_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">http.cookies.Morsel.js_output()</span></code></a> is deprecated and will be
|
||
removed in Python 3.19.</p></li>
|
||
<li><p><a class="reference internal" href="../library/http.cookies.html#http.cookies.BaseCookie.js_output" title="http.cookies.BaseCookie.js_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">http.cookies.BaseCookie.js_output()</span></code></a> is deprecated and will be
|
||
removed in Python 3.19.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/imaplib.html#module-imaplib" title="imaplib: IMAP4 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">imaplib</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>Altering <a class="reference internal" href="../library/imaplib.html#imaplib.IMAP4.file" title="imaplib.IMAP4.file"><code class="xref py py-attr docutils literal notranslate"><span class="pre">IMAP4.file</span></code></a> is now deprecated
|
||
and slated for removal in Python 3.19. This property is now unused
|
||
and changing its value does not automatically close the current file.</p>
|
||
<p>Before Python 3.14, this property was used to implement the corresponding
|
||
<code class="docutils literal notranslate"><span class="pre">read()</span></code> and <code class="docutils literal notranslate"><span class="pre">readline()</span></code> methods for <a class="reference internal" href="../library/imaplib.html#imaplib.IMAP4" title="imaplib.IMAP4"><code class="xref py py-class docutils literal notranslate"><span class="pre">IMAP4</span></code></a> but this
|
||
is no longer the case since then.</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="pending-removal-in-python-3-20">
|
||
<h3>Pending removal in Python 3.20<a class="headerlink" href="#pending-removal-in-python-3-20" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>Calling the <code class="docutils literal notranslate"><span class="pre">__new__()</span></code> method of <a class="reference internal" href="../library/struct.html#struct.Struct" title="struct.Struct"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct.Struct</span></code></a> without the
|
||
<em>format</em> argument is deprecated and will be removed in Python 3.20. Calling
|
||
<a class="reference internal" href="../reference/datamodel.html#object.__init__" title="object.__init__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__init__()</span></code></a> method on initialized <code class="xref py py-class docutils literal notranslate"><span class="pre">Struct</span></code>
|
||
objects is deprecated and will be removed in Python 3.20.</p>
|
||
<p>(Contributed by Sergey B Kirpichev and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143715">gh-143715</a>.)</p>
|
||
</li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">__version__</span></code>, <code class="docutils literal notranslate"><span class="pre">version</span></code> and <code class="docutils literal notranslate"><span class="pre">VERSION</span></code> attributes have been
|
||
deprecated in these standard library modules and will be removed in
|
||
Python 3.20. Use <a class="reference internal" href="../library/sys.html#sys.version_info" title="sys.version_info"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.version_info</span></code></a> instead.</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/argparse.html#module-argparse" title="argparse: Command-line option and argument parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">argparse</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/csv.html#module-csv" title="csv: Write and read tabular data to and from delimited files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">csv</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/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></p></li>
|
||
<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">ctypes.macholib</span></code></p></li>
|
||
<li><p><a class="reference internal" href="../library/decimal.html#module-decimal" title="decimal: Implementation of the General Decimal Arithmetic Specification."><code class="xref py py-mod docutils literal notranslate"><span class="pre">decimal</span></code></a> (use <a class="reference internal" href="../library/decimal.html#decimal.SPEC_VERSION" title="decimal.SPEC_VERSION"><code class="xref py py-data docutils literal notranslate"><span class="pre">decimal.SPEC_VERSION</span></code></a> instead)</p></li>
|
||
<li><p><a class="reference internal" href="../library/http.server.html#module-http.server" title="http.server: HTTP server and request handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">http.server</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/imaplib.html#module-imaplib" title="imaplib: IMAP4 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">imaplib</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/ipaddress.html#module-ipaddress" title="ipaddress: IPv4/IPv6 manipulation library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ipaddress</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/json.html#module-json" title="json: Encode and decode the JSON format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">json</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/logging.html#module-logging" title="logging: Flexible event logging system for applications."><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code></a> (<code class="docutils literal notranslate"><span class="pre">__date__</span></code> also deprecated)</p></li>
|
||
<li><p><a class="reference internal" href="../library/optparse.html#module-optparse" title="optparse: Command-line option parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">optparse</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/pickle.html#module-pickle" title="pickle: Convert Python objects to streams of bytes and back."><code class="xref py py-mod docutils literal notranslate"><span class="pre">pickle</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/platform.html#module-platform" title="platform: Retrieves as much platform identifying data as possible."><code class="xref py py-mod docutils literal notranslate"><span class="pre">platform</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">re</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/socketserver.html#module-socketserver" title="socketserver: A framework for network servers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socketserver</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tabnanny.html#module-tabnanny" title="tabnanny: Tool for detecting white space related problems in Python source files in a directory tree."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tabnanny</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tarfile.html#module-tarfile" title="tarfile: Read and write tar-format archive files."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tarfile</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tkinter.font.html#module-tkinter.font" title="tkinter.font: Tkinter font-wrapping class"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.font</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/tkinter.ttk.html#module-tkinter.ttk" title="tkinter.ttk: Tk themed widget set"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tkinter.ttk</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/wsgiref.html#module-wsgiref.simple_server" title="wsgiref.simple_server: A simple WSGI HTTP server."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref.simple_server</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code></a></p></li>
|
||
<li><p><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.expatreader</span></code></p></li>
|
||
<li><p><a class="reference internal" href="../library/xml.sax.handler.html#module-xml.sax.handler" title="xml.sax.handler: Base classes for SAX event handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.handler</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../library/zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a></p></li>
|
||
</ul>
|
||
<p>(Contributed by Hugo van Kemenade and Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/76007">gh-76007</a>.)</p>
|
||
</li>
|
||
<li><p>Deprecations defined by <span class="target" id="index-63"></span><a class="pep reference external" href="https://peps.python.org/pep-0829/"><strong>PEP 829</strong></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Warnings are produced for <code class="docutils literal notranslate"><span class="pre">import</span></code> lines found in <code class="file docutils literal notranslate"><em><span class="pre">name</span></em><span class="pre">.pth</span></code>
|
||
files.</p></li>
|
||
<li><p><code class="file docutils literal notranslate"><em><span class="pre">name</span></em><span class="pre">.pth</span></code> files are no longer decoded in the locale encoding by
|
||
default. They <strong>MUST</strong> be encoded in <code class="docutils literal notranslate"><span class="pre">utf-8-sig</span></code>.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Barry Warsaw in <a class="reference external" href="https://github.com/python/cpython/issues/148641">gh-148641</a>.)</p>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/ast.html#module-ast" title="ast: Abstract Syntax Tree classes and manipulation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ast</span></code></a>:</p>
|
||
<ul class="simple">
|
||
<li><p>Creating instances of abstract AST nodes (such as <a class="reference internal" href="../library/ast.html#ast.AST" title="ast.AST"><code class="xref py py-class docutils literal notranslate"><span class="pre">ast.AST</span></code></a>
|
||
or <code class="xref py py-class docutils literal notranslate"><span class="pre">ast.expr</span></code>) is deprecated and will raise an error in Python 3.20.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/typing.html#module-typing" title="typing: Support for type hints (see :pep:`484`)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">typing</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>It is deprecated to call <a class="reference internal" href="../builtins/functions.html#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a> and <a class="reference internal" href="../builtins/functions.html#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a> checks on
|
||
protocol classes that were not explicitly decorated with <code class="xref py py-func docutils literal notranslate"><span class="pre">runtime_checkable()</span></code>
|
||
but that inherit from a runtime-checkable protocol class.
|
||
This will raise a <a class="reference internal" href="../builtins/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> in Python 3.20.</p>
|
||
<p>(Contributed by Bartosz Sławecki in <a class="reference external" href="https://github.com/python/cpython/issues/132604">gh-132604</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="pending-removal-in-future-versions">
|
||
<h3>Pending removal in future versions<a class="headerlink" href="#pending-removal-in-future-versions" title="Link to this heading">¶</a></h3>
|
||
<p>The following APIs will be removed in the future,
|
||
although there is currently no date scheduled for their removal.</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../library/argparse.html#module-argparse" title="argparse: Command-line option and argument parsing library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">argparse</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>Nesting argument groups and nesting mutually exclusive
|
||
groups are deprecated.</p></li>
|
||
<li><p>Passing the undocumented keyword argument <em>prefix_chars</em> to
|
||
<a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser.add_argument_group" title="argparse.ArgumentParser.add_argument_group"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_argument_group()</span></code></a> is now
|
||
deprecated.</p></li>
|
||
<li><p>The <a class="reference internal" href="../library/argparse.html#argparse.FileType" title="argparse.FileType"><code class="xref py py-class docutils literal notranslate"><span class="pre">argparse.FileType</span></code></a> type converter is deprecated.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code></a>:</p>
|
||
<ul>
|
||
<li><p>Generators: <code class="docutils literal notranslate"><span class="pre">throw(type,</span> <span class="pre">exc,</span> <span class="pre">tb)</span></code> and <code class="docutils literal notranslate"><span class="pre">athrow(type,</span> <span class="pre">exc,</span> <span class="pre">tb)</span></code>
|
||
signature is deprecated: use <code class="docutils literal notranslate"><span class="pre">throw(exc)</span></code> and <code class="docutils literal notranslate"><span class="pre">athrow(exc)</span></code> instead,
|
||
the single argument signature.</p></li>
|
||
<li><p>Currently Python accepts numeric literals immediately followed by keywords,
|
||
for example <code class="docutils literal notranslate"><span class="pre">0in</span> <span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">1or</span> <span class="pre">x</span></code>, <code class="docutils literal notranslate"><span class="pre">0if</span> <span class="pre">1else</span> <span class="pre">2</span></code>. It allows confusing and
|
||
ambiguous expressions like <code class="docutils literal notranslate"><span class="pre">[0x1for</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">y]</span></code> (which can be interpreted as
|
||
<code class="docutils literal notranslate"><span class="pre">[0x1</span> <span class="pre">for</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">y]</span></code> or <code class="docutils literal notranslate"><span class="pre">[0x1f</span> <span class="pre">or</span> <span class="pre">x</span> <span class="pre">in</span> <span class="pre">y]</span></code>). A syntax warning is raised
|
||
if the numeric literal is immediately followed by one of keywords
|
||
<a class="reference internal" href="../reference/expressions.html#and"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">and</span></code></a>, <a class="reference internal" href="../reference/compound_stmts.html#else"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">else</span></code></a>, <a class="reference internal" href="../reference/compound_stmts.html#for"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">for</span></code></a>, <a class="reference internal" href="../reference/compound_stmts.html#if"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">if</span></code></a>,
|
||
<a class="reference internal" href="../reference/expressions.html#in"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">in</span></code></a>, <a class="reference internal" href="../reference/expressions.html#is"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">is</span></code></a> and <a class="reference internal" href="../reference/expressions.html#or"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">or</span></code></a>. In a future release it
|
||
will be changed to a syntax error. (<a class="reference external" href="https://github.com/python/cpython/issues/87999">gh-87999</a>)</p></li>
|
||
<li><p>Support for <code class="docutils literal notranslate"><span class="pre">__index__()</span></code> and <code class="docutils literal notranslate"><span class="pre">__int__()</span></code> method returning non-int type:
|
||
these methods will be required to return an instance of a strict subclass of
|
||
<a class="reference internal" href="../builtins/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.</p></li>
|
||
<li><p>Support for <code class="docutils literal notranslate"><span class="pre">__float__()</span></code> method returning a strict subclass of
|
||
<a class="reference internal" href="../builtins/functions.html#float" title="float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>: these methods will be required to return an instance of
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code>.</p></li>
|
||
<li><p>Support for <code class="docutils literal notranslate"><span class="pre">__complex__()</span></code> method returning a strict subclass of
|
||
<a class="reference internal" href="../builtins/functions.html#complex" title="complex"><code class="xref py py-class docutils literal notranslate"><span class="pre">complex</span></code></a>: these methods will be required to return an instance of
|
||
<code class="xref py py-class docutils literal notranslate"><span class="pre">complex</span></code>.</p></li>
|
||
<li><p>Passing a complex number as the <em>real</em> or <em>imag</em> argument in the
|
||
<a class="reference internal" href="../builtins/functions.html#complex" title="complex"><code class="xref py py-func docutils literal notranslate"><span class="pre">complex()</span></code></a> constructor is now deprecated; it should only be passed
|
||
as a single positional argument.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/109218">gh-109218</a>.)</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/calendar.html#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a>: <code class="docutils literal notranslate"><span class="pre">calendar.January</span></code> and <code class="docutils literal notranslate"><span class="pre">calendar.February</span></code> constants are
|
||
deprecated and replaced by <a class="reference internal" href="../library/calendar.html#calendar.JANUARY" title="calendar.JANUARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">calendar.JANUARY</span></code></a> and
|
||
<a class="reference internal" href="../library/calendar.html#calendar.FEBRUARY" title="calendar.FEBRUARY"><code class="xref py py-data docutils literal notranslate"><span class="pre">calendar.FEBRUARY</span></code></a>.
|
||
(Contributed by Prince Roshan in <a class="reference external" href="https://github.com/python/cpython/issues/103636">gh-103636</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/codecs.html#module-codecs" title="codecs: Encode and decode data and streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">codecs</span></code></a>: use <a class="reference internal" href="../builtins/functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> instead of <a class="reference internal" href="../library/codecs.html#codecs.open" title="codecs.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">codecs.open()</span></code></a>. (<a class="reference external" href="https://github.com/python/cpython/issues/133038">gh-133038</a>)</p></li>
|
||
<li><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">codeobject.co_lnotab</span></code>: use the <a class="reference internal" href="../reference/datamodel.html#codeobject.co_lines" title="codeobject.co_lines"><code class="xref py py-meth docutils literal notranslate"><span class="pre">codeobject.co_lines()</span></code></a> method
|
||
instead.</p></li>
|
||
<li><p><a class="reference internal" href="../library/datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a>:</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/datetime.html#datetime.datetime.utcnow" title="datetime.datetime.utcnow"><code class="xref py py-meth docutils literal notranslate"><span class="pre">utcnow()</span></code></a>:
|
||
use <code class="docutils literal notranslate"><span class="pre">datetime.datetime.now(tz=datetime.UTC)</span></code>.</p></li>
|
||
<li><p><a class="reference internal" href="../library/datetime.html#datetime.datetime.utcfromtimestamp" title="datetime.datetime.utcfromtimestamp"><code class="xref py py-meth docutils literal notranslate"><span class="pre">utcfromtimestamp()</span></code></a>:
|
||
use <code class="docutils literal notranslate"><span class="pre">datetime.datetime.fromtimestamp(timestamp,</span> <span class="pre">tz=datetime.UTC)</span></code>.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/gettext.html#module-gettext" title="gettext: Multilingual internationalization services."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gettext</span></code></a>: Plural value must be an integer.</p></li>
|
||
<li><p><a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a>:</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/importlib.html#importlib.util.cache_from_source" title="importlib.util.cache_from_source"><code class="xref py py-func docutils literal notranslate"><span class="pre">cache_from_source()</span></code></a> <em>debug_override</em> parameter is
|
||
deprecated: use the <em>optimization</em> parameter instead.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/importlib.metadata.html#module-importlib.metadata" title="importlib.metadata: Accessing package metadata"><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib.metadata</span></code></a>:</p>
|
||
<ul>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">EntryPoints</span></code> tuple interface.</p></li>
|
||
<li><p>Implicit <code class="docutils literal notranslate"><span class="pre">None</span></code> on return values.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/logging.html#module-logging" title="logging: Flexible event logging system for applications."><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code></a>: the <code class="docutils literal notranslate"><span class="pre">warn()</span></code> method has been deprecated
|
||
since Python 3.3, use <a class="reference internal" href="../library/logging.html#logging.warning" title="logging.warning"><code class="xref py py-meth docutils literal notranslate"><span class="pre">warning()</span></code></a> instead.</p></li>
|
||
<li><p><a class="reference internal" href="../library/mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a>: Use of StringIO input and text mode is deprecated, use
|
||
BytesIO and binary mode instead.</p></li>
|
||
<li><p><a class="reference internal" href="../library/os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a>: Calling <a class="reference internal" href="../library/os.html#os.register_at_fork" title="os.register_at_fork"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.register_at_fork()</span></code></a> in a multi-threaded process.</p></li>
|
||
<li><p><a class="reference internal" href="../library/os.path.html#module-os.path" title="os.path: Operations on pathnames."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os.path</span></code></a>: <a class="reference internal" href="../library/os.path.html#os.path.commonprefix" title="os.path.commonprefix"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.path.commonprefix()</span></code></a> is deprecated, use
|
||
<a class="reference internal" href="../library/os.path.html#os.path.commonpath" title="os.path.commonpath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.path.commonpath()</span></code></a> for path prefixes. The <code class="xref py py-func docutils literal notranslate"><span class="pre">os.path.commonprefix()</span></code>
|
||
function is being deprecated due to having a misleading name and module.
|
||
The function is not safe to use for path prefixes despite being included in a
|
||
module about path manipulation, meaning it is easy to accidentally
|
||
introduce path traversal vulnerabilities into Python programs by using this
|
||
function.</p></li>
|
||
<li><p><code class="xref py py-class docutils literal notranslate"><span class="pre">pydoc.ErrorDuringImport</span></code>: A tuple value for <em>exc_info</em> parameter is
|
||
deprecated, use an exception instance.</p></li>
|
||
<li><p><a class="reference internal" href="../library/re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">re</span></code></a>: More strict rules are now applied for numerical group references
|
||
and group names in regular expressions. Only sequence of ASCII digits is now
|
||
accepted as a numerical reference. The group name in bytes patterns and
|
||
replacement strings can now only contain ASCII letters and digits and
|
||
underscore.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/91760">gh-91760</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/shutil.html#module-shutil" title="shutil: High-level file operations, including copying."><code class="xref py py-mod docutils literal notranslate"><span class="pre">shutil</span></code></a>: <a class="reference internal" href="../library/shutil.html#shutil.rmtree" title="shutil.rmtree"><code class="xref py py-func docutils literal notranslate"><span class="pre">rmtree()</span></code></a>’s <em>onerror</em> parameter is deprecated in
|
||
Python 3.12; use the <em>onexc</em> parameter instead.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#module-ssl" title="ssl: TLS/SSL wrapper for socket objects"><code class="xref py py-mod docutils literal notranslate"><span class="pre">ssl</span></code></a> options and protocols:</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLContext</span></code></a> without protocol argument is deprecated.</p></li>
|
||
<li><p><a class="reference internal" href="../library/ssl.html#ssl.SSLContext" title="ssl.SSLContext"><code class="xref py py-class docutils literal notranslate"><span class="pre">ssl.SSLContext</span></code></a>: <a class="reference internal" href="../library/ssl.html#ssl.SSLContext.set_npn_protocols" title="ssl.SSLContext.set_npn_protocols"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_npn_protocols()</span></code></a> and
|
||
<code class="xref py py-meth docutils literal notranslate"><span class="pre">selected_npn_protocol()</span></code> are deprecated: use ALPN
|
||
instead.</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.OP_NO_SSL*</span></code> options</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.OP_NO_TLS*</span></code> options</p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.PROTOCOL_SSLv3</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.PROTOCOL_TLS</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.PROTOCOL_TLSv1</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.PROTOCOL_TLSv1_1</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.PROTOCOL_TLSv1_2</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.TLSVersion.SSLv3</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.TLSVersion.TLSv1</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">ssl.TLSVersion.TLSv1_1</span></code></p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/threading.html#module-threading" title="threading: Thread-based parallelism."><code class="xref py py-mod docutils literal notranslate"><span class="pre">threading</span></code></a> methods:</p>
|
||
<ul>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.Condition.notifyAll()</span></code>: use <a class="reference internal" href="../library/threading.html#threading.Condition.notify_all" title="threading.Condition.notify_all"><code class="xref py py-meth docutils literal notranslate"><span class="pre">notify_all()</span></code></a>.</p></li>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.Event.isSet()</span></code>: use <a class="reference internal" href="../library/threading.html#threading.Event.is_set" title="threading.Event.is_set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_set()</span></code></a>.</p></li>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.Thread.isDaemon()</span></code>, <a class="reference internal" href="../library/threading.html#threading.Thread.setDaemon" title="threading.Thread.setDaemon"><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.Thread.setDaemon()</span></code></a>:
|
||
use <a class="reference internal" href="../library/threading.html#threading.Thread.daemon" title="threading.Thread.daemon"><code class="xref py py-attr docutils literal notranslate"><span class="pre">threading.Thread.daemon</span></code></a> attribute.</p></li>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.Thread.getName()</span></code>, <a class="reference internal" href="../library/threading.html#threading.Thread.setName" title="threading.Thread.setName"><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.Thread.setName()</span></code></a>:
|
||
use <a class="reference internal" href="../library/threading.html#threading.Thread.name" title="threading.Thread.name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">threading.Thread.name</span></code></a> attribute.</p></li>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.currentThread()</span></code>: use <a class="reference internal" href="../library/threading.html#threading.current_thread" title="threading.current_thread"><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.current_thread()</span></code></a>.</p></li>
|
||
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.activeCount()</span></code>: use <a class="reference internal" href="../library/threading.html#threading.active_count" title="threading.active_count"><code class="xref py py-meth docutils literal notranslate"><span class="pre">threading.active_count()</span></code></a>.</p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/typing.html#typing.Text" title="typing.Text"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.Text</span></code></a> (<a class="reference external" href="https://github.com/python/cpython/issues/92332">gh-92332</a>).</p></li>
|
||
<li><p>The internal class <code class="docutils literal notranslate"><span class="pre">typing._UnionGenericAlias</span></code> is no longer used to implement
|
||
<a class="reference internal" href="../library/typing.html#typing.Union" title="typing.Union"><code class="xref py py-class docutils literal notranslate"><span class="pre">typing.Union</span></code></a>. To preserve compatibility with users using this private
|
||
class, a compatibility shim will be provided until at least Python 3.17. (Contributed by
|
||
Jelle Zijlstra in <a class="reference external" href="https://github.com/python/cpython/issues/105499">gh-105499</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/unittest.html#unittest.IsolatedAsyncioTestCase" title="unittest.IsolatedAsyncioTestCase"><code class="xref py py-class docutils literal notranslate"><span class="pre">unittest.IsolatedAsyncioTestCase</span></code></a>: it is deprecated to return a value
|
||
that is not <code class="docutils literal notranslate"><span class="pre">None</span></code> from a test case.</p></li>
|
||
<li><p><a class="reference internal" href="../library/urllib.parse.html#module-urllib.parse" title="urllib.parse: Parse URLs into or assemble them from components."><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.parse</span></code></a> deprecated functions: <a class="reference internal" href="../library/urllib.parse.html#urllib.parse.urlparse" title="urllib.parse.urlparse"><code class="xref py py-func docutils literal notranslate"><span class="pre">urlparse()</span></code></a> instead</p>
|
||
<ul>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splitattr()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splithost()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splitnport()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splitpasswd()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splitport()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splitquery()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splittag()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splittype()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splituser()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">splitvalue()</span></code></p></li>
|
||
<li><p><code class="docutils literal notranslate"><span class="pre">to_bytes()</span></code></p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/wsgiref.html#module-wsgiref" title="wsgiref: WSGI Utilities and Reference Implementation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref</span></code></a>: <code class="docutils literal notranslate"><span class="pre">SimpleHandler.stdout.write()</span></code> should not do partial
|
||
writes.</p></li>
|
||
<li><p><a class="reference internal" href="../library/xml.etree.elementtree.html#module-xml.etree.ElementTree" title="xml.etree.ElementTree: Implementation of the ElementTree API."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.etree.ElementTree</span></code></a>: Testing the truth value of an
|
||
<a class="reference internal" href="../library/xml.etree.elementtree.html#xml.etree.ElementTree.Element" title="xml.etree.ElementTree.Element"><code class="xref py py-class docutils literal notranslate"><span class="pre">Element</span></code></a> is deprecated. In a future release it
|
||
will always return <code class="docutils literal notranslate"><span class="pre">True</span></code>. Prefer explicit <code class="docutils literal notranslate"><span class="pre">len(elem)</span></code> or
|
||
<code class="docutils literal notranslate"><span class="pre">elem</span> <span class="pre">is</span> <span class="pre">not</span> <span class="pre">None</span></code> tests instead.</p></li>
|
||
<li><p><a class="reference internal" href="../library/sys.html#sys._clear_type_cache" title="sys._clear_type_cache"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys._clear_type_cache()</span></code></a> is deprecated:
|
||
use <a class="reference internal" href="../library/sys.html#sys._clear_internal_caches" title="sys._clear_internal_caches"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys._clear_internal_caches()</span></code></a> instead.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="soft-deprecations">
|
||
<h3>Soft deprecations<a class="headerlink" href="#soft-deprecations" title="Link to this heading">¶</a></h3>
|
||
<p>There are no plans to remove <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a> APIs.</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/re.html#re.match" title="re.match"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.match()</span></code></a> and <a class="reference internal" href="../library/re.html#re.Pattern.match" title="re.Pattern.match"><code class="xref py py-meth docutils literal notranslate"><span class="pre">re.Pattern.match()</span></code></a> are now
|
||
<a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a> in favor of the new <a class="reference internal" href="../library/re.html#re.prefixmatch" title="re.prefixmatch"><code class="xref py py-func docutils literal notranslate"><span class="pre">re.prefixmatch()</span></code></a> and
|
||
<a class="reference internal" href="../library/re.html#re.Pattern.prefixmatch" title="re.Pattern.prefixmatch"><code class="xref py py-meth docutils literal notranslate"><span class="pre">re.Pattern.prefixmatch()</span></code></a> APIs, which have been added as alternate,
|
||
more explicit names. These are intended to be used to alleviate confusion
|
||
around what <em>match</em> means by following the Zen of Python’s <em>“Explicit is
|
||
better than implicit”</em> mantra. Most other language regular expression
|
||
libraries use an API named <em>match</em> to mean what Python has always called
|
||
<em>search</em>.</p>
|
||
<p>We <strong>do not</strong> plan to remove the older <code class="xref py py-func docutils literal notranslate"><span class="pre">match()</span></code> name, as it has been
|
||
used in code for over 30 years. Code supporting older versions of Python
|
||
should continue to use <code class="xref py py-func docutils literal notranslate"><span class="pre">match()</span></code>, while new code should prefer
|
||
<code class="xref py py-func docutils literal notranslate"><span class="pre">prefixmatch()</span></code>. See <a class="reference internal" href="../library/re.html#prefixmatch-vs-match"><span class="std std-ref">prefixmatch() vs. match()</span></a>.</p>
|
||
<p>(Contributed by Gregory P. Smith in <a class="reference external" href="https://github.com/python/cpython/issues/86519">gh-86519</a> and
|
||
Hugo van Kemenade in <a class="reference external" href="https://github.com/python/cpython/issues/148100">gh-148100</a>.)</p>
|
||
</li>
|
||
<li><p>Using <code class="docutils literal notranslate"><span class="pre">'F'</span></code> and <code class="docutils literal notranslate"><span class="pre">'D'</span></code> format type codes of the <a class="reference internal" href="../library/struct.html#module-struct" title="struct: Interpret bytes as packed binary data."><code class="xref py py-mod docutils literal notranslate"><span class="pre">struct</span></code></a> module
|
||
now are <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a> in favor of two-letter forms <code class="docutils literal notranslate"><span class="pre">'Zf'</span></code>
|
||
and <code class="docutils literal notranslate"><span class="pre">'Zd'</span></code>.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/121249">gh-121249</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
<section id="c-api-changes">
|
||
<h2>C API changes<a class="headerlink" href="#c-api-changes" title="Link to this heading">¶</a></h2>
|
||
<section id="id9">
|
||
<h3>New features<a class="headerlink" href="#id9" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>Add <a class="reference internal" href="../c-api/arg.html#c.PyArg_ParseArray" title="PyArg_ParseArray"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArg_ParseArray()</span></code></a> and <a class="reference internal" href="../c-api/arg.html#c.PyArg_ParseArrayAndKeywords" title="PyArg_ParseArrayAndKeywords"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArg_ParseArrayAndKeywords()</span></code></a>
|
||
functions to parse arguments of functions using the <a class="reference internal" href="../c-api/structures.html#c.METH_FASTCALL" title="METH_FASTCALL"><code class="xref c c-macro docutils literal notranslate"><span class="pre">METH_FASTCALL</span></code></a>
|
||
calling convention.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/144175">gh-144175</a>.)</p></li>
|
||
<li><p>Add the following functions for the new <a class="reference internal" href="../builtins/stdtypes.html#frozendict" title="frozendict"><code class="xref py py-class docutils literal notranslate"><span class="pre">frozendict</span></code></a> type:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../c-api/dict.html#c.PyAnyDict_Check" title="PyAnyDict_Check"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyAnyDict_Check()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/dict.html#c.PyAnyDict_CheckExact" title="PyAnyDict_CheckExact"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyAnyDict_CheckExact()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/dict.html#c.PyFrozenDict_Check" title="PyFrozenDict_Check"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyFrozenDict_Check()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/dict.html#c.PyFrozenDict_CheckExact" title="PyFrozenDict_CheckExact"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyFrozenDict_CheckExact()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/dict.html#c.PyFrozenDict_New" title="PyFrozenDict_New"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyFrozenDict_New()</span></code></a></p></li>
|
||
</ul>
|
||
<p>(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/141510">gh-141510</a>.)</p>
|
||
</li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/lifecycle.html#c.PyObject_CallFinalizerFromDealloc" title="PyObject_CallFinalizerFromDealloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_CallFinalizerFromDealloc()</span></code></a> function to the limited C
|
||
API.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/146063">gh-146063</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/sys.html#c.PySys_GetAttr" title="PySys_GetAttr"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_GetAttr()</span></code></a>, <a class="reference internal" href="../c-api/sys.html#c.PySys_GetAttrString" title="PySys_GetAttrString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_GetAttrString()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/sys.html#c.PySys_GetOptionalAttr" title="PySys_GetOptionalAttr"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_GetOptionalAttr()</span></code></a>, and <a class="reference internal" href="../c-api/sys.html#c.PySys_GetOptionalAttrString" title="PySys_GetOptionalAttrString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_GetOptionalAttrString()</span></code></a>
|
||
functions as replacements for <a class="reference internal" href="../c-api/sys.html#c.PySys_GetObject" title="PySys_GetObject"><code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_GetObject()</span></code></a>.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/108512">gh-108512</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/unicode.html#c.PyUnstable_Unicode_GET_CACHED_HASH" title="PyUnstable_Unicode_GET_CACHED_HASH"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnstable_Unicode_GET_CACHED_HASH()</span></code></a> to get the cached hash of
|
||
a string. See the documentation for caveats.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/131510">gh-131510</a>.)</p></li>
|
||
<li><p>Add API for checking an extension module’s ABI compatibility:
|
||
<a class="reference internal" href="../c-api/module.html#c.Py_mod_abi" title="Py_mod_abi"><code class="xref c c-data docutils literal notranslate"><span class="pre">Py_mod_abi</span></code></a>, <a class="reference internal" href="../c-api/stable.html#c.PyABIInfo_Check" title="PyABIInfo_Check"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyABIInfo_Check()</span></code></a>,
|
||
and <a class="reference internal" href="../c-api/stable.html#c.PyABIInfo_VAR" title="PyABIInfo_VAR"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PyABIInfo_VAR</span></code></a>.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/137210">gh-137210</a>.)</p></li>
|
||
</ul>
|
||
<ul id="whatsnew315-pybyteswriter">
|
||
<li><p>Implement <span class="target" id="index-64"></span><a class="pep reference external" href="https://peps.python.org/pep-0782/"><strong>PEP 782</strong></a>, the <a class="reference internal" href="../c-api/bytes.html#pybyteswriter"><span class="std std-ref">PyBytesWriter API</span></a>.
|
||
Add functions:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_Create" title="PyBytesWriter_Create"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_Create()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_Discard" title="PyBytesWriter_Discard"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_Discard()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_Finish" title="PyBytesWriter_Finish"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_Finish()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_FinishWithPointer" title="PyBytesWriter_FinishWithPointer"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_FinishWithPointer()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_FinishWithSize" title="PyBytesWriter_FinishWithSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_FinishWithSize()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_Format" title="PyBytesWriter_Format"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_Format()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_GetData" title="PyBytesWriter_GetData"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_GetData()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_GetSize" title="PyBytesWriter_GetSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_GetSize()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_Grow" title="PyBytesWriter_Grow"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_Grow()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_GrowAndUpdatePointer" title="PyBytesWriter_GrowAndUpdatePointer"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_GrowAndUpdatePointer()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_Resize" title="PyBytesWriter_Resize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_Resize()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter_WriteBytes" title="PyBytesWriter_WriteBytes"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytesWriter_WriteBytes()</span></code></a></p></li>
|
||
</ul>
|
||
<p>(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/129813">gh-129813</a>.)</p>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../c-api/synchronization.html#c.PyCriticalSection" title="PyCriticalSection"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyCriticalSection</span></code></a> and related functions are added to the Stable
|
||
ABI.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/149225">gh-149225</a>.)</p></li>
|
||
<li><p>Add a new <a class="reference internal" href="../c-api/import.html#c.PyImport_CreateModuleFromInitfunc" title="PyImport_CreateModuleFromInitfunc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_CreateModuleFromInitfunc()</span></code></a> C API for creating
|
||
a module from a <em>spec</em> and <em>initfunc</em>.
|
||
(Contributed by Itamar Oren in <a class="reference external" href="https://github.com/python/cpython/issues/116146">gh-116146</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/tuple.html#c.PyTuple_FromArray" title="PyTuple_FromArray"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyTuple_FromArray()</span></code></a> to create a <a class="reference internal" href="../builtins/stdtypes.html#tuple" title="tuple"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a> from an array.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/111489">gh-111489</a>.)</p></li>
|
||
<li><p>Add a new module export hook,
|
||
<a class="reference internal" href="../c-api/extension-modules.html#c.PyModExport_modulename" title="PyModExport_modulename"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModExport_*</span></code></a>.</p>
|
||
<p>(Contributed by Petr Viktorin in <span class="target" id="index-65"></span><a class="pep reference external" href="https://peps.python.org/pep-0793/"><strong>PEP 793</strong></a> and <a class="reference external" href="https://github.com/python/cpython/issues/140550">gh-140550</a>.)</p>
|
||
</li>
|
||
<li><p>Add functions that are guaranteed to be safe for use in
|
||
<a class="reference internal" href="../c-api/typeobj.html#c.PyTypeObject.tp_traverse" title="PyTypeObject.tp_traverse"><code class="xref c c-member docutils literal notranslate"><span class="pre">tp_traverse</span></code></a> handlers:
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyObject_GetTypeData_DuringGC" title="PyObject_GetTypeData_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_GetTypeData_DuringGC()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyObject_GetItemData_DuringGC" title="PyObject_GetItemData_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_GetItemData_DuringGC()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyType_GetModuleState_DuringGC" title="PyType_GetModuleState_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_GetModuleState_DuringGC()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyModule_GetState_DuringGC" title="PyModule_GetState_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModule_GetState_DuringGC()</span></code></a>, <a class="reference internal" href="../c-api/gcsupport.html#c.PyModule_GetToken_DuringGC" title="PyModule_GetToken_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModule_GetToken_DuringGC()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyType_GetBaseByToken_DuringGC" title="PyType_GetBaseByToken_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_GetBaseByToken_DuringGC()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyType_GetModule_DuringGC" title="PyType_GetModule_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_GetModule_DuringGC()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/gcsupport.html#c.PyType_GetModuleByToken_DuringGC" title="PyType_GetModuleByToken_DuringGC"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_GetModuleByToken_DuringGC()</span></code></a>.
|
||
(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/145925">gh-145925</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/object.html#c.PyObject_Dump" title="PyObject_Dump"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_Dump()</span></code></a> to dump an object to <code class="docutils literal notranslate"><span class="pre">stderr</span></code>.
|
||
It should only be used for debugging.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/141070">gh-141070</a>.)</p></li>
|
||
<li><p>Implement <span class="target" id="index-66"></span><a class="pep reference external" href="https://peps.python.org/pep-0820/"><strong>PEP 820</strong></a>: <code class="docutils literal notranslate"><span class="pre">PySlot</span></code> – Unified slot system for the C API.
|
||
See <a class="reference internal" href="../c-api/slots.html#capi-slots"><span class="std std-ref">Definition slots</span></a> for documentation.</p>
|
||
<p>This adds:</p>
|
||
<ul class="simple">
|
||
<li><p>The <a class="reference internal" href="../c-api/slots.html#c.PySlot" title="PySlot"><code class="xref c c-type docutils literal notranslate"><span class="pre">PySlot</span></code></a> struct;</p></li>
|
||
<li><p>the <a class="reference internal" href="../c-api/type.html#c.PyType_FromSlots" title="PyType_FromSlots"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_FromSlots()</span></code></a> function;</p></li>
|
||
<li><p>new slot IDs: <a class="reference internal" href="../c-api/slots.html#c.Py_slot_end" title="Py_slot_end"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_slot_end</span></code></a>, <a class="reference internal" href="../c-api/slots.html#c.Py_slot_invalid" title="Py_slot_invalid"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_slot_invalid</span></code></a>;
|
||
<a class="reference internal" href="../c-api/slots.html#c.Py_slot_subslots" title="Py_slot_subslots"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_slot_subslots</span></code></a>, <a class="reference internal" href="../c-api/type.html#c.Py_tp_slots" title="Py_tp_slots"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_slots</span></code></a>,
|
||
<a class="reference internal" href="../c-api/module.html#c.Py_mod_slots" title="Py_mod_slots"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_mod_slots</span></code></a>;
|
||
<a class="reference internal" href="../c-api/type.html#c.Py_tp_name" title="Py_tp_name"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_name</span></code></a>, <a class="reference internal" href="../c-api/type.html#c.Py_tp_basicsize" title="Py_tp_basicsize"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_basicsize</span></code></a>,
|
||
<a class="reference internal" href="../c-api/type.html#c.Py_tp_extra_basicsize" title="Py_tp_extra_basicsize"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_extra_basicsize</span></code></a>, <a class="reference internal" href="../c-api/type.html#c.Py_tp_itemsize" title="Py_tp_itemsize"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_itemsize</span></code></a>,
|
||
<a class="reference internal" href="../c-api/type.html#c.Py_tp_flags" title="Py_tp_flags"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_flags</span></code></a>, <a class="reference internal" href="../c-api/type.html#c.Py_tp_metaclass" title="Py_tp_metaclass"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_metaclass</span></code></a>,
|
||
<a class="reference internal" href="../c-api/type.html#c.Py_tp_module" title="Py_tp_module"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_module</span></code></a>;</p></li>
|
||
<li><p>convenience macros: <a class="reference internal" href="../c-api/slots.html#c.PySlot_DATA" title="PySlot_DATA"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_DATA</span></code></a>, <a class="reference internal" href="../c-api/slots.html#c.PySlot_FUNC" title="PySlot_FUNC"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_FUNC</span></code></a>,
|
||
<a class="reference internal" href="../c-api/slots.html#c.PySlot_SIZE" title="PySlot_SIZE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_SIZE</span></code></a>, <a class="reference internal" href="../c-api/slots.html#c.PySlot_INT64" title="PySlot_INT64"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_INT64</span></code></a>, <a class="reference internal" href="../c-api/slots.html#c.PySlot_UINT64" title="PySlot_UINT64"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_UINT64</span></code></a>,
|
||
<a class="reference internal" href="../c-api/slots.html#c.PySlot_STATIC_DATA" title="PySlot_STATIC_DATA"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_STATIC_DATA</span></code></a>, <a class="reference internal" href="../c-api/slots.html#c.PySlot_END" title="PySlot_END"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_END</span></code></a>,
|
||
<a class="reference internal" href="../c-api/slots.html#c.PySlot_PTR" title="PySlot_PTR"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_PTR</span></code></a>, <a class="reference internal" href="../c-api/slots.html#c.PySlot_PTR_STATIC" title="PySlot_PTR_STATIC"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PySlot_PTR_STATIC</span></code></a>.</p></li>
|
||
</ul>
|
||
<p>The <a class="reference internal" href="../c-api/module.html#c.PyModule_FromSlotsAndSpec" title="PyModule_FromSlotsAndSpec"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModule_FromSlotsAndSpec()</span></code></a> function and
|
||
<code class="docutils literal notranslate"><span class="pre">PyModExport</span></code> <a class="reference internal" href="../c-api/extension-modules.html#extension-export-hook"><span class="std std-ref">module export hook</span></a> also
|
||
use the new <code class="xref c c-type docutils literal notranslate"><span class="pre">PySlot</span></code> struct.</p>
|
||
<p>The following functions are <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../c-api/type.html#c.PyType_FromSpec" title="PyType_FromSpec"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_FromSpec()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/type.html#c.PyType_FromSpecWithBases" title="PyType_FromSpecWithBases"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_FromSpecWithBases()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/type.html#c.PyType_FromModuleAndSpec" title="PyType_FromModuleAndSpec"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_FromModuleAndSpec()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/type.html#c.PyType_FromMetaclass" title="PyType_FromMetaclass"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyType_FromMetaclass()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/module.html#c.PyModule_FromDefAndSpec" title="PyModule_FromDefAndSpec"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModule_FromDefAndSpec()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/module.html#c.PyModule_FromDefAndSpec2" title="PyModule_FromDefAndSpec2"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModule_FromDefAndSpec2()</span></code></a></p></li>
|
||
<li><p><a class="reference internal" href="../c-api/module.html#c.PyModule_ExecDef" title="PyModule_ExecDef"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyModule_ExecDef()</span></code></a></p></li>
|
||
</ul>
|
||
<p>The slots <a class="reference internal" href="../c-api/type.html#c.Py_tp_bases" title="Py_tp_bases"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_bases</span></code></a> and <a class="reference internal" href="../c-api/type.html#c.Py_tp_base" title="Py_tp_base"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_base</span></code></a> are now
|
||
equivalent: they can be set either to a single type or a tuple of types.
|
||
The <code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_tp_bases</span></code> slot is preferred; the other is ignored if both
|
||
are specified.</p>
|
||
<p>(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/149044">gh-149044</a>.)</p>
|
||
</li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/threads.html#c.PyUnstable_ThreadState_SetStackProtection" title="PyUnstable_ThreadState_SetStackProtection"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnstable_ThreadState_SetStackProtection()</span></code></a> and
|
||
<a class="reference internal" href="../c-api/threads.html#c.PyUnstable_ThreadState_ResetStackProtection" title="PyUnstable_ThreadState_ResetStackProtection"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnstable_ThreadState_ResetStackProtection()</span></code></a> functions to set
|
||
the stack protection base address and stack protection size of a Python
|
||
thread state.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/139653">gh-139653</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/object.html#c.PyUnstable_SetImmortal" title="PyUnstable_SetImmortal"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnstable_SetImmortal()</span></code></a> C API function to mark objects as <a class="reference internal" href="../glossary.html#term-immortal"><span class="xref std std-term">immortal</span></a>.
|
||
(Contributed by Kumar Aditya in <a class="reference external" href="https://github.com/python/cpython/issues/143300">gh-143300</a>.)</p></li>
|
||
<li><p>Restore private provisional <code class="docutils literal notranslate"><span class="pre">_Py_InitializeMain()</span></code> function removed in
|
||
Python 3.14.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/142417">gh-142417</a>.)</p></li>
|
||
<li><p>Add <a class="reference internal" href="../c-api/exceptions.html#c.PyUnstable_DumpTraceback" title="PyUnstable_DumpTraceback"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnstable_DumpTraceback()</span></code></a> and
|
||
<a class="reference internal" href="../c-api/exceptions.html#c.PyUnstable_DumpTracebackThreads" title="PyUnstable_DumpTracebackThreads"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnstable_DumpTracebackThreads()</span></code></a> functions to output Python
|
||
stacktraces.
|
||
(Contributed by Alex Malyshev in <a class="reference external" href="https://github.com/python/cpython/issues/145559">gh-145559</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="changed-c-apis">
|
||
<h3>Changed C APIs<a class="headerlink" href="#changed-c-apis" title="Link to this heading">¶</a></h3>
|
||
<ul class="simple">
|
||
<li><p>If the <a class="reference internal" href="../c-api/typeobj.html#c.Py_TPFLAGS_MANAGED_DICT" title="Py_TPFLAGS_MANAGED_DICT"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_TPFLAGS_MANAGED_DICT</span></code></a> or <a class="reference internal" href="../c-api/typeobj.html#c.Py_TPFLAGS_MANAGED_WEAKREF" title="Py_TPFLAGS_MANAGED_WEAKREF"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_TPFLAGS_MANAGED_WEAKREF</span></code></a>
|
||
flag is set then <a class="reference internal" href="../c-api/typeobj.html#c.Py_TPFLAGS_HAVE_GC" title="Py_TPFLAGS_HAVE_GC"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_TPFLAGS_HAVE_GC</span></code></a> must be set too.
|
||
(Contributed by Sergey Miryanov in <a class="reference external" href="https://github.com/python/cpython/issues/134786">gh-134786</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/datetime.html#c.PyDateTime_IMPORT" title="PyDateTime_IMPORT"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PyDateTime_IMPORT</span></code></a> is now thread safe. Code that directly checks <code class="docutils literal notranslate"><span class="pre">PyDateTimeAPI</span></code>
|
||
for <code class="docutils literal notranslate"><span class="pre">NULL</span></code> should be updated to call <code class="xref c c-macro docutils literal notranslate"><span class="pre">PyDateTime_IMPORT</span></code> instead.
|
||
(Contributed by Kumar Aditya in <a class="reference external" href="https://github.com/python/cpython/issues/141563">gh-141563</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="removed-c-apis">
|
||
<h3>Removed C APIs<a class="headerlink" href="#removed-c-apis" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>Remove deprecated <code class="docutils literal notranslate"><span class="pre">PyUnicode</span></code> functions:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsDecodedObject()</span></code>:
|
||
Use <a class="reference internal" href="../c-api/codec.html#c.PyCodec_Decode" title="PyCodec_Decode"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCodec_Decode()</span></code></a> instead.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsDecodedUnicode()</span></code>:
|
||
Use <a class="reference internal" href="../c-api/codec.html#c.PyCodec_Decode" title="PyCodec_Decode"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCodec_Decode()</span></code></a> instead; note that some codecs (for example, “base64”)
|
||
may return a type other than <a class="reference internal" href="../builtins/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, such as <a class="reference internal" href="../builtins/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsEncodedObject()</span></code>:
|
||
Use <a class="reference internal" href="../c-api/codec.html#c.PyCodec_Encode" title="PyCodec_Encode"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCodec_Encode()</span></code></a> instead.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_AsEncodedUnicode()</span></code>:
|
||
Use <a class="reference internal" href="../c-api/codec.html#c.PyCodec_Encode" title="PyCodec_Encode"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyCodec_Encode()</span></code></a> instead; note that some codecs (for example, “base64”)
|
||
may return a type other than <a class="reference internal" href="../builtins/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>, such as <a class="reference internal" href="../builtins/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Stan Ulbrych in <a class="reference external" href="https://github.com/python/cpython/issues/133612">gh-133612</a>.)</p>
|
||
</li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_ImportModuleNoBlock()</span></code>: deprecated alias
|
||
of <a class="reference internal" href="../c-api/import.html#c.PyImport_ImportModule" title="PyImport_ImportModule"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyImport_ImportModule()</span></code></a>.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133644">gh-133644</a>.)</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">PyWeakref_GetObject()</span></code> and <code class="xref c c-macro docutils literal notranslate"><span class="pre">PyWeakref_GET_OBJECT</span></code>:
|
||
use <a class="reference internal" href="../c-api/weakref.html#c.PyWeakref_GetRef" title="PyWeakref_GetRef"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyWeakref_GetRef()</span></code></a> instead. The <a class="reference external" href="https://github.com/python/pythoncapi-compat">pythoncapi-compat project</a>
|
||
can be used to get <code class="xref c c-func docutils literal notranslate"><span class="pre">PyWeakref_GetRef()</span></code> on Python 3.12 and older.
|
||
(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133644">gh-133644</a>.)</p></li>
|
||
<li><p>Remove deprecated <code class="xref c c-func docutils literal notranslate"><span class="pre">PySys_ResetWarnOptions()</span></code>.
|
||
Clear <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a> and <code class="xref py py-data docutils literal notranslate"><span class="pre">warnings.filters</span></code> instead.</p>
|
||
<p>(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/138886">gh-138886</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
<p>The following functions are removed in favor of <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get()</span></code></a>.
|
||
The <a class="reference external" href="https://github.com/python/pythoncapi-compat">pythoncapi-compat project</a> can be used to get <code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get()</span></code>
|
||
on Python 3.13 and older.</p>
|
||
<ul>
|
||
<li><p>Python initialization functions:</p>
|
||
<ul class="simple">
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_GetExecPrefix()</span></code>:
|
||
use <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("base_exec_prefix")</span></code></a>
|
||
(<a class="reference internal" href="../library/sys.html#sys.base_exec_prefix" title="sys.base_exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.base_exec_prefix</span></code></a>) instead.
|
||
Use <code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("exec_prefix")</span></code>
|
||
(<a class="reference internal" href="../library/sys.html#sys.exec_prefix" title="sys.exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exec_prefix</span></code></a>) if <a class="reference internal" href="../library/venv.html#venv-def"><span class="std std-ref">virtual environments</span></a>
|
||
need to be handled.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_GetPath()</span></code>:
|
||
use <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("module_search_paths")</span></code></a>
|
||
(<a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>) instead.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_GetPrefix()</span></code>:
|
||
use <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("base_prefix")</span></code></a>
|
||
(<a class="reference internal" href="../library/sys.html#sys.base_prefix" title="sys.base_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.base_prefix</span></code></a>) instead.
|
||
Use <code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("prefix")</span></code>
|
||
(<a class="reference internal" href="../library/sys.html#sys.prefix" title="sys.prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.prefix</span></code></a>) if <a class="reference internal" href="../library/venv.html#venv-def"><span class="std std-ref">virtual environments</span></a>
|
||
need to be handled.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_GetProgramFullPath()</span></code>:
|
||
use <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("executable")</span></code></a>
|
||
(<a class="reference internal" href="../library/sys.html#sys.executable" title="sys.executable"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.executable</span></code></a>) instead.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_GetProgramName()</span></code>:
|
||
use <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("executable")</span></code></a>
|
||
(<a class="reference internal" href="../library/sys.html#sys.executable" title="sys.executable"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.executable</span></code></a>) instead.</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_GetPythonHome()</span></code>:
|
||
use <a class="reference internal" href="../c-api/init_config.html#c.PyConfig_Get" title="PyConfig_Get"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Get("home")</span></code></a> or the
|
||
<span class="target" id="index-67"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a> environment variable instead.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/133644">gh-133644</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="deprecated-c-apis">
|
||
<h3>Deprecated C APIs<a class="headerlink" href="#deprecated-c-apis" title="Link to this heading">¶</a></h3>
|
||
<ul>
|
||
<li><p>Deprecate <span class="target" id="index-68"></span><a class="pep reference external" href="https://peps.python.org/pep-0456/"><strong>PEP 456</strong></a> support for providing an external definition
|
||
of the string hashing scheme. Removal is scheduled for Python 3.19.</p>
|
||
<p>Previously, embedders could define <a class="reference internal" href="../c-api/hash.html#c.Py_HASH_ALGORITHM" title="Py_HASH_ALGORITHM"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_HASH_ALGORITHM</span></code></a> to be
|
||
<code class="docutils literal notranslate"><span class="pre">Py_HASH_EXTERNAL</span></code> to indicate that the hashing scheme was provided
|
||
externally but this feature was undocumented, untested and most likely
|
||
unused.</p>
|
||
<p>(Contributed by Bénédikt Tran in <a class="reference external" href="https://github.com/python/cpython/issues/141226">gh-141226</a>.)</p>
|
||
</li>
|
||
<li><p>For unsigned integer formats in <a class="reference internal" href="../c-api/arg.html#c.PyArg_ParseTuple" title="PyArg_ParseTuple"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyArg_ParseTuple()</span></code></a>,
|
||
accepting Python integers with value that is larger than the maximal value
|
||
for the C type or less than the minimal value for the corresponding
|
||
signed integer type of the same size is now deprecated.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/132629">gh-132629</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/bytes.html#c.PyBytes_FromStringAndSize" title="PyBytes_FromStringAndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytes_FromStringAndSize(NULL,</span> <span class="pre">len)</span></code></a>
|
||
and <a class="reference internal" href="../c-api/bytes.html#c._PyBytes_Resize" title="_PyBytes_Resize"><code class="xref c c-func docutils literal notranslate"><span class="pre">_PyBytes_Resize()</span></code></a> are <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>,
|
||
use the <a class="reference internal" href="../c-api/bytes.html#c.PyBytesWriter" title="PyBytesWriter"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyBytesWriter</span></code></a> API instead.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/129813">gh-129813</a>.)</p></li>
|
||
<li><p><code class="xref c c-func docutils literal notranslate"><span class="pre">_PyObject_CallMethodId()</span></code>, <code class="xref c c-func docutils literal notranslate"><span class="pre">_PyObject_GetAttrId()</span></code> and
|
||
<code class="xref c c-func docutils literal notranslate"><span class="pre">_PyUnicode_FromId()</span></code> are deprecated since Python 3.15 and will be removed in
|
||
Python 3.20. Instead, use <a class="reference internal" href="../c-api/unicode.html#c.PyUnicode_InternFromString" title="PyUnicode_InternFromString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_InternFromString()</span></code></a> and cache the result in
|
||
the module state, then call <a class="reference internal" href="../c-api/call.html#c.PyObject_CallMethod" title="PyObject_CallMethod"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_CallMethod()</span></code></a> or
|
||
<a class="reference internal" href="../c-api/object.html#c.PyObject_GetAttr" title="PyObject_GetAttr"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyObject_GetAttr()</span></code></a>.
|
||
(Contributed by Victor Stinner in <a class="reference external" href="https://github.com/python/cpython/issues/141049">gh-141049</a>.)</p></li>
|
||
<li><p>Deprecate <a class="reference internal" href="../c-api/complex.html#c.PyComplexObject.cval" title="PyComplexObject.cval"><code class="xref c c-member docutils literal notranslate"><span class="pre">cval</span></code></a> field of the
|
||
<a class="reference internal" href="../c-api/complex.html#c.PyComplexObject" title="PyComplexObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyComplexObject</span></code></a> type.
|
||
Use <a class="reference internal" href="../c-api/complex.html#c.PyComplex_AsCComplex" title="PyComplex_AsCComplex"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyComplex_AsCComplex()</span></code></a> and <a class="reference internal" href="../c-api/complex.html#c.PyComplex_FromCComplex" title="PyComplex_FromCComplex"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyComplex_FromCComplex()</span></code></a>
|
||
to convert a Python complex number to/from the C <a class="reference internal" href="../c-api/complex.html#c.Py_complex" title="Py_complex"><code class="xref c c-type docutils literal notranslate"><span class="pre">Py_complex</span></code></a>
|
||
representation.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/128813">gh-128813</a>.)</p></li>
|
||
<li><p>Functions <a class="reference internal" href="../c-api/complex.html#c._Py_c_sum" title="_Py_c_sum"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_sum()</span></code></a>, <a class="reference internal" href="../c-api/complex.html#c._Py_c_diff" title="_Py_c_diff"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_diff()</span></code></a>, <a class="reference internal" href="../c-api/complex.html#c._Py_c_neg" title="_Py_c_neg"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_neg()</span></code></a>,
|
||
<a class="reference internal" href="../c-api/complex.html#c._Py_c_prod" title="_Py_c_prod"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_prod()</span></code></a>, <a class="reference internal" href="../c-api/complex.html#c._Py_c_quot" title="_Py_c_quot"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_quot()</span></code></a>, <a class="reference internal" href="../c-api/complex.html#c._Py_c_pow" title="_Py_c_pow"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_pow()</span></code></a> and
|
||
<a class="reference internal" href="../c-api/complex.html#c._Py_c_abs" title="_Py_c_abs"><code class="xref c c-func docutils literal notranslate"><span class="pre">_Py_c_abs()</span></code></a> are <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/128813">gh-128813</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/init_config.html#c.PyConfig.bytes_warning" title="PyConfig.bytes_warning"><code class="xref c c-member docutils literal notranslate"><span class="pre">bytes_warning</span></code></a> is deprecated
|
||
since Python 3.15 and will be removed in Python 3.17.
|
||
(Contributed by Nikita Sobolev in <a class="reference external" href="https://github.com/python/cpython/issues/136355">gh-136355</a>.)</p></li>
|
||
<li><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_INFINITY</span></code> macro is <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>,
|
||
use the C11 standard <code class="docutils literal notranslate"><span class="pre"><math.h></span></code> <code class="xref c c-macro docutils literal notranslate"><span class="pre">INFINITY</span></code> instead.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/141004">gh-141004</a>.)</p></li>
|
||
<li><p>The following macros are <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a>:</p>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../c-api/intro.html#c.Py_ALIGNED" title="Py_ALIGNED"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_ALIGNED</span></code></a>: Prefer <code class="docutils literal notranslate"><span class="pre">alignas</span></code> instead.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/intro.html#c.PY_FORMAT_SIZE_T" title="PY_FORMAT_SIZE_T"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_FORMAT_SIZE_T</span></code></a>: Use <code class="docutils literal notranslate"><span class="pre">"z"</span></code> directly.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/intro.html#c.Py_LL" title="Py_LL"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_LL</span></code></a> and <a class="reference internal" href="../c-api/intro.html#c.Py_ULL" title="Py_ULL"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_ULL</span></code></a>:
|
||
Use standard suffixes, <code class="docutils literal notranslate"><span class="pre">LL</span></code> and <code class="docutils literal notranslate"><span class="pre">ULL</span></code>.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/intro.html#c.PY_LONG_LONG" title="PY_LONG_LONG"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_LONG_LONG</span></code></a>, <a class="reference internal" href="../c-api/intro.html#c.PY_LLONG_MIN" title="PY_LLONG_MIN"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_LLONG_MIN</span></code></a>, <a class="reference internal" href="../c-api/intro.html#c.PY_LLONG_MAX" title="PY_LLONG_MAX"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_LLONG_MAX</span></code></a>,
|
||
<a class="reference internal" href="../c-api/intro.html#c.PY_ULLONG_MAX" title="PY_ULLONG_MAX"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_ULLONG_MAX</span></code></a>, <a class="reference internal" href="../c-api/intro.html#c.PY_INT32_T" title="PY_INT32_T"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_INT32_T</span></code></a>, <a class="reference internal" href="../c-api/intro.html#c.PY_UINT32_T" title="PY_UINT32_T"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_UINT32_T</span></code></a>,
|
||
<a class="reference internal" href="../c-api/intro.html#c.PY_INT64_T" title="PY_INT64_T"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_INT64_T</span></code></a>, <a class="reference internal" href="../c-api/intro.html#c.PY_UINT64_T" title="PY_UINT64_T"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_UINT64_T</span></code></a>, <a class="reference internal" href="../c-api/intro.html#c.PY_SIZE_MAX" title="PY_SIZE_MAX"><code class="xref c c-macro docutils literal notranslate"><span class="pre">PY_SIZE_MAX</span></code></a>:
|
||
Use C99 types/limits.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/intro.html#c.Py_UNICODE_SIZE" title="Py_UNICODE_SIZE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_UNICODE_SIZE</span></code></a>: Use <code class="docutils literal notranslate"><span class="pre">sizeof(wchar_t)</span></code> directly.</p></li>
|
||
<li><p><a class="reference internal" href="../c-api/intro.html#c.Py_VA_COPY" title="Py_VA_COPY"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_VA_COPY</span></code></a>: Use <code class="docutils literal notranslate"><span class="pre">va_copy</span></code> directly.</p></li>
|
||
</ul>
|
||
<p>The macro <a class="reference internal" href="../c-api/intro.html#c.Py_UNICODE_WIDE" title="Py_UNICODE_WIDE"><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_UNICODE_WIDE</span></code></a>, which was scheduled for removal,
|
||
is <a class="reference internal" href="../glossary.html#term-soft-deprecated"><span class="xref std std-term">soft deprecated</span></a> instead.</p>
|
||
<p>(Contributed by Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/146175">gh-146175</a>.)</p>
|
||
</li>
|
||
<li><p><code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_MATH_El</span></code> and <code class="xref c c-macro docutils literal notranslate"><span class="pre">Py_MATH_PIl</span></code> are deprecated
|
||
since Python 3.15 and will be removed in Python 3.20.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/141004">gh-141004</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
<section id="build-changes">
|
||
<h2>Build changes<a class="headerlink" href="#build-changes" title="Link to this heading">¶</a></h2>
|
||
<ul>
|
||
<li><p>Removed implicit fallback to the bundled copy of the <code class="docutils literal notranslate"><span class="pre">libmpdec</span></code> library.
|
||
Now this should be explicitly enabled with <a class="reference internal" href="../using/configure.html#cmdoption-with-system-libmpdec"><code class="xref std std-option docutils literal notranslate"><span class="pre">--with-system-libmpdec</span></code></a>
|
||
set to <code class="docutils literal notranslate"><span class="pre">no</span></code> or with <code class="xref std std-option docutils literal notranslate"><span class="pre">--without-system-libmpdec</span></code>.
|
||
(Contributed by Sergey B Kirpichev in <a class="reference external" href="https://github.com/python/cpython/issues/115119">gh-115119</a>.)</p></li>
|
||
<li><p>The new configure option <a class="reference internal" href="../using/configure.html#cmdoption-with-missing-stdlib-config"><code class="xref std std-option docutils literal notranslate"><span class="pre">--with-missing-stdlib-config=FILE</span></code></a> allows
|
||
distributors to pass a <a class="reference external" href="https://www.json.org/json-en.html">JSON</a>
|
||
configuration file containing custom error messages for <a class="reference internal" href="../glossary.html#term-standard-library"><span class="xref std std-term">standard library</span></a>
|
||
modules that are missing or packaged separately.
|
||
(Contributed by Stan Ulbrych and Petr Viktorin in <a class="reference external" href="https://github.com/python/cpython/issues/139707">gh-139707</a>.)</p></li>
|
||
<li><p>The new configure option <a class="reference internal" href="../using/configure.html#cmdoption-with-pymalloc-hugepages"><code class="xref std std-option docutils literal notranslate"><span class="pre">--with-pymalloc-hugepages</span></code></a> enables huge
|
||
page support for <a class="reference internal" href="../c-api/memory.html#pymalloc"><span class="std std-ref">pymalloc</span></a> arenas. When enabled, arena size
|
||
increases to 2 MiB and allocation uses <code class="docutils literal notranslate"><span class="pre">MAP_HUGETLB</span></code> (Linux) or
|
||
<code class="docutils literal notranslate"><span class="pre">MEM_LARGE_PAGES</span></code> (Windows) with automatic fallback to regular pages.
|
||
On Windows, use <code class="docutils literal notranslate"><span class="pre">build.bat</span> <span class="pre">--pymalloc-hugepages</span></code>.
|
||
At runtime, huge pages must be explicitly enabled by setting the
|
||
<span class="target" id="index-69"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHON_PYMALLOC_HUGEPAGES"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHON_PYMALLOC_HUGEPAGES</span></code></a> environment variable to <code class="docutils literal notranslate"><span class="pre">1</span></code>.
|
||
(Contributed by Pablo Galindo Salgado in <a class="reference external" href="https://github.com/python/cpython/issues/144319">gh-144319</a>.)</p></li>
|
||
<li><p>Annotating anonymous mmap usage is now supported if the Linux kernel supports
|
||
<em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/PR_SET_VMA(2const)">PR_SET_VMA_ANON_NAME</a></em> (Linux 5.17 or newer).
|
||
Annotations are visible in <code class="docutils literal notranslate"><span class="pre">/proc/<pid>/maps</span></code> if the kernel supports the feature
|
||
and <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> is passed to Python,
|
||
or Python is built in <a class="reference internal" href="../using/configure.html#debug-build"><span class="std std-ref">debug mode</span></a>.
|
||
(Contributed by Donghee Na in <a class="reference external" href="https://github.com/python/cpython/issues/141770">gh-141770</a>.)</p></li>
|
||
<li><p>CPython is now built with frame pointers enabled by default
|
||
(<span class="target" id="index-70"></span><a class="pep reference external" href="https://peps.python.org/pep-0831/"><strong>PEP 831</strong></a>). Pass <a class="reference internal" href="../using/configure.html#cmdoption-without-frame-pointers"><code class="xref std std-option docutils literal notranslate"><span class="pre">--without-frame-pointers</span></code></a> to opt out.</p>
|
||
<p>Authors of C extensions and native libraries built with custom build
|
||
systems should ensure the unwind chain is intact.
|
||
This is usually done by adding <code class="docutils literal notranslate"><span class="pre">-fno-omit-frame-pointer</span></code> and
|
||
similar flags to <code class="docutils literal notranslate"><span class="pre">CFLAGS</span></code>. See <a class="reference internal" href="../using/configure.html#cmdoption-without-frame-pointers"><code class="xref std std-option docutils literal notranslate"><span class="pre">--without-frame-pointers</span></code></a>
|
||
documentation for the specific flags Python uses.</p>
|
||
<p>(Contributed by Pablo Galindo Salgado and Savannah Ostrowski in <a class="reference external" href="https://github.com/python/cpython/issues/149201">gh-149201</a>.)</p>
|
||
</li>
|
||
</ul>
|
||
<ul class="simple" id="whatsnew315-windows-tail-calling-interpreter">
|
||
<li><p>64-bit builds using Visual Studio 2026 (MSVC 18) may now use the new
|
||
<a class="reference internal" href="3.14.html#whatsnew314-tail-call-interpreter"><span class="std std-ref">tail-calling interpreter</span></a>.
|
||
Results on Visual Studio 18.1.1 report between
|
||
<a class="reference external" href="https://github.com/faster-cpython/ideas/blob/main/results/5800X-msvc.pgo2-vs-msvc.pgo.tc.svg">15-20%</a>
|
||
speedup on the geometric mean of pyperformance on Windows x86-64 over
|
||
the switch-case interpreter on an AMD Ryzen 7 5800X. We have
|
||
observed speedups ranging from 14% for large pure-Python libraries
|
||
to 40% for long-running small pure-Python scripts on Windows.
|
||
This was made possible by a new feature introduced in MSVC 18,
|
||
which the official Windows 64-bit binaries on <a class="reference external" href="https://www.python.org/downloads/windows/">python.org</a> now use.
|
||
(Contributed by Chris Eibl, Ken Jin, and Brandt Bucher in <a class="reference external" href="https://github.com/python/cpython/issues/143068">gh-143068</a>.
|
||
Special thanks to Steve Dower, and the MSVC team including Hulon Jenkins.)</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="porting-to-python-3-15">
|
||
<h2>Porting to Python 3.15<a class="headerlink" href="#porting-to-python-3-15" title="Link to this heading">¶</a></h2>
|
||
<p>This section lists previously described changes and other bugfixes
|
||
that may require changes to your code.</p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection" title="sqlite3.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">sqlite3.Connection</span></code></a> APIs have been cleaned up.</p>
|
||
<ul class="simple">
|
||
<li><p>All parameters of <a class="reference internal" href="../library/sqlite3.html#sqlite3.connect" title="sqlite3.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">sqlite3.connect()</span></code></a> except <em>database</em> are now keyword-only.</p></li>
|
||
<li><p>The first three parameters of methods <a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.create_function" title="sqlite3.Connection.create_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_function()</span></code></a>
|
||
and <a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.create_aggregate" title="sqlite3.Connection.create_aggregate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_aggregate()</span></code></a> are now positional-only.</p></li>
|
||
<li><p>The first parameter of methods <a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.set_authorizer" title="sqlite3.Connection.set_authorizer"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_authorizer()</span></code></a>,
|
||
<a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.set_progress_handler" title="sqlite3.Connection.set_progress_handler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_progress_handler()</span></code></a> and
|
||
<a class="reference internal" href="../library/sqlite3.html#sqlite3.Connection.set_trace_callback" title="sqlite3.Connection.set_trace_callback"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_trace_callback()</span></code></a> is now positional-only.</p></li>
|
||
</ul>
|
||
<p>(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/133595">gh-133595</a>.)</p>
|
||
</li>
|
||
<li><p><a class="reference internal" href="../library/resource.html#resource.RLIM_INFINITY" title="resource.RLIM_INFINITY"><code class="xref py py-data docutils literal notranslate"><span class="pre">resource.RLIM_INFINITY</span></code></a> is now always positive.
|
||
Passing a negative integer value that corresponded to its old value
|
||
(such as <code class="docutils literal notranslate"><span class="pre">-1</span></code> or <code class="docutils literal notranslate"><span class="pre">-3</span></code>, depending on platform) to
|
||
<a class="reference internal" href="../library/resource.html#resource.setrlimit" title="resource.setrlimit"><code class="xref py py-func docutils literal notranslate"><span class="pre">resource.setrlimit()</span></code></a> and <a class="reference internal" href="../library/resource.html#resource.prlimit" title="resource.prlimit"><code class="xref py py-func docutils literal notranslate"><span class="pre">resource.prlimit()</span></code></a> is now deprecated.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/137044">gh-137044</a>.)</p></li>
|
||
<li><p><a class="reference internal" href="../library/mmap.html#mmap.mmap.resize" title="mmap.mmap.resize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">mmap.mmap.resize()</span></code></a> has been removed on platforms that don’t support the
|
||
underlying syscall, instead of raising a <a class="reference internal" href="../builtins/exceptions.html#SystemError" title="SystemError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SystemError</span></code></a>.
|
||
(Contributed by An Long in <a class="reference external" href="https://github.com/python/cpython/issues/138205">gh-138205</a>.)</p></li>
|
||
<li><p>A resource warning is now emitted for an unclosed
|
||
<a class="reference internal" href="../library/xml.etree.elementtree.html#xml.etree.ElementTree.iterparse" title="xml.etree.ElementTree.iterparse"><code class="xref py py-func docutils literal notranslate"><span class="pre">xml.etree.ElementTree.iterparse()</span></code></a> iterator if it opened a file.
|
||
Use its <code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code> method or the <a class="reference internal" href="../library/contextlib.html#contextlib.closing" title="contextlib.closing"><code class="xref py py-func docutils literal notranslate"><span class="pre">contextlib.closing()</span></code></a> context
|
||
manager to close it.
|
||
(Contributed by Osama Abdelkader and Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/140601">gh-140601</a>.)</p></li>
|
||
<li><p>If a short option and a single-dash long option are passed to
|
||
<a class="reference internal" href="../library/argparse.html#argparse.ArgumentParser.add_argument" title="argparse.ArgumentParser.add_argument"><code class="xref py py-meth docutils literal notranslate"><span class="pre">argparse.ArgumentParser.add_argument()</span></code></a>, <em>dest</em> is now inferred from
|
||
the single-dash long option. For example, in <code class="docutils literal notranslate"><span class="pre">add_argument('-f',</span> <span class="pre">'-foo')</span></code>,
|
||
<em>dest</em> is now <code class="docutils literal notranslate"><span class="pre">'foo'</span></code> instead of <code class="docutils literal notranslate"><span class="pre">'f'</span></code>.
|
||
Pass an explicit <em>dest</em> argument to preserve the old behavior.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/138697">gh-138697</a>.)</p></li>
|
||
<li><p>Padding of input no longer required in <a class="reference internal" href="../library/base64.html#base64.urlsafe_b64decode" title="base64.urlsafe_b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">base64.urlsafe_b64decode()</span></code></a>.
|
||
Pass a new argument <code class="docutils literal notranslate"><span class="pre">padded=True</span></code> or use <a class="reference internal" href="../library/base64.html#base64.b64decode" title="base64.b64decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">base64.b64decode()</span></code></a>
|
||
with argument <code class="docutils literal notranslate"><span class="pre">altchars=b'-_'</span></code> (this works with older Python versions)
|
||
to make padding required.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/73613">gh-73613</a>.)</p></li>
|
||
<li><p>Since <a class="reference internal" href="../library/unittest.html#unittest.TestCase.assertWarns" title="unittest.TestCase.assertWarns"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unittest.TestCase.assertWarns()</span></code></a> and
|
||
<a class="reference internal" href="../library/unittest.html#unittest.TestCase.assertWarnsRegex" title="unittest.TestCase.assertWarnsRegex"><code class="xref py py-meth docutils literal notranslate"><span class="pre">unittest.TestCase.assertWarnsRegex()</span></code></a> no longer swallow warnings that
|
||
do not match the specified category or regex, your tests may start leaking
|
||
some warnings that were previously masked.
|
||
Use warning filters to silence them or additional <code class="xref py py-meth docutils literal notranslate"><span class="pre">assertWarns*()</span></code>
|
||
to catch and check them.
|
||
(Contributed by Serhiy Storchaka in <a class="reference external" href="https://github.com/python/cpython/issues/143231">gh-143231</a>.)</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
||
<div class="sphinxsidebarwrapper">
|
||
<div>
|
||
<h3><a href="../contents.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">What’s new in Python 3.15</a><ul>
|
||
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release highlights</a></li>
|
||
<li><a class="reference internal" href="#new-features">New features</a><ul>
|
||
<li><a class="reference internal" href="#pep-810-explicit-lazy-imports"><strong>PEP 810</strong>: Explicit lazy imports</a></li>
|
||
<li><a class="reference internal" href="#pep-814-add-frozendict-built-in-type"><strong>PEP 814</strong>: Add frozendict built-in type</a></li>
|
||
<li><a class="reference internal" href="#pep-661-add-sentinel-built-in-type"><strong>PEP 661</strong>: Add sentinel built-in type</a></li>
|
||
<li><a class="reference internal" href="#pep-799-a-dedicated-profiling-package"><strong>PEP 799</strong>: A dedicated profiling package</a></li>
|
||
<li><a class="reference internal" href="#tachyon-high-frequency-statistical-sampling-profiler">Tachyon: High-frequency statistical sampling profiler</a></li>
|
||
<li><a class="reference internal" href="#pep-831-frame-pointers-enabled-by-default"><strong>PEP 831</strong>: Frame pointers enabled by default</a></li>
|
||
<li><a class="reference internal" href="#pep-798-unpacking-in-comprehensions"><strong>PEP 798</strong>: Unpacking in comprehensions</a></li>
|
||
<li><a class="reference internal" href="#pep-829-package-startup-configuration-files"><strong>PEP 829</strong>: Package startup configuration files</a></li>
|
||
<li><a class="reference internal" href="#pep-803-stable-abi-for-free-threaded-builds"><strong>PEP 803</strong>: Stable ABI for free-threaded builds</a></li>
|
||
<li><a class="reference internal" href="#pep-788-protecting-the-c-api-from-interpreter-finalization"><strong>PEP 788</strong>: Protecting the C API from interpreter finalization</a></li>
|
||
<li><a class="reference internal" href="#improved-error-messages">Improved error messages</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#other-language-changes">Other language changes</a></li>
|
||
<li><a class="reference internal" href="#default-interactive-shell">Default interactive shell</a></li>
|
||
<li><a class="reference internal" href="#new-modules">New modules</a><ul>
|
||
<li><a class="reference internal" href="#math-integer">math.integer</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#improved-modules">Improved modules</a><ul>
|
||
<li><a class="reference internal" href="#argparse">argparse</a></li>
|
||
<li><a class="reference internal" href="#array">array</a></li>
|
||
<li><a class="reference internal" href="#ast">ast</a></li>
|
||
<li><a class="reference internal" href="#asyncio">asyncio</a></li>
|
||
<li><a class="reference internal" href="#base64">base64</a></li>
|
||
<li><a class="reference internal" href="#binascii">binascii</a></li>
|
||
<li><a class="reference internal" href="#calendar">calendar</a></li>
|
||
<li><a class="reference internal" href="#collections">collections</a></li>
|
||
<li><a class="reference internal" href="#concurrent-futures">concurrent.futures</a></li>
|
||
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
|
||
<li><a class="reference internal" href="#ctypes">ctypes</a></li>
|
||
<li><a class="reference internal" href="#dataclasses">dataclasses</a></li>
|
||
<li><a class="reference internal" href="#dbm">dbm</a></li>
|
||
<li><a class="reference internal" href="#difflib">difflib</a></li>
|
||
<li><a class="reference internal" href="#email">email</a></li>
|
||
<li><a class="reference internal" href="#faulthandler">faulthandler</a></li>
|
||
<li><a class="reference internal" href="#functools">functools</a></li>
|
||
<li><a class="reference internal" href="#gc">gc</a></li>
|
||
<li><a class="reference internal" href="#hashlib">hashlib</a></li>
|
||
<li><a class="reference internal" href="#http-client">http.client</a></li>
|
||
<li><a class="reference internal" href="#http-server">http.server</a></li>
|
||
<li><a class="reference internal" href="#importlib-metadata">importlib.metadata</a></li>
|
||
<li><a class="reference internal" href="#inspect">inspect</a></li>
|
||
<li><a class="reference internal" href="#json">json</a></li>
|
||
<li><a class="reference internal" href="#locale">locale</a></li>
|
||
<li><a class="reference internal" href="#math">math</a></li>
|
||
<li><a class="reference internal" href="#mimetypes">mimetypes</a></li>
|
||
<li><a class="reference internal" href="#mmap">mmap</a></li>
|
||
<li><a class="reference internal" href="#os">os</a></li>
|
||
<li><a class="reference internal" href="#os-path">os.path</a></li>
|
||
<li><a class="reference internal" href="#pathlib">pathlib</a></li>
|
||
<li><a class="reference internal" href="#pdb">pdb</a></li>
|
||
<li><a class="reference internal" href="#pickle">pickle</a></li>
|
||
<li><a class="reference internal" href="#pickletools">pickletools</a></li>
|
||
<li><a class="reference internal" href="#pprint">pprint</a></li>
|
||
<li><a class="reference internal" href="#re">re</a></li>
|
||
<li><a class="reference internal" href="#resource">resource</a></li>
|
||
<li><a class="reference internal" href="#shelve">shelve</a></li>
|
||
<li><a class="reference internal" href="#socket">socket</a></li>
|
||
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
|
||
<li><a class="reference internal" href="#ssl">ssl</a></li>
|
||
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
|
||
<li><a class="reference internal" href="#symtable">symtable</a></li>
|
||
<li><a class="reference internal" href="#sys">sys</a></li>
|
||
<li><a class="reference internal" href="#sys-monitoring">sys.monitoring</a></li>
|
||
<li><a class="reference internal" href="#tarfile">tarfile</a></li>
|
||
<li><a class="reference internal" href="#threading">threading</a></li>
|
||
<li><a class="reference internal" href="#timeit">timeit</a></li>
|
||
<li><a class="reference internal" href="#tkinter">tkinter</a></li>
|
||
<li><a class="reference internal" href="#tokenize">tokenize</a></li>
|
||
<li><a class="reference internal" href="#tomllib">tomllib</a></li>
|
||
<li><a class="reference internal" href="#types">types</a></li>
|
||
<li><a class="reference internal" href="#typing">typing</a></li>
|
||
<li><a class="reference internal" href="#unicodedata">unicodedata</a></li>
|
||
<li><a class="reference internal" href="#unittest">unittest</a></li>
|
||
<li><a class="reference internal" href="#urllib-parse">urllib.parse</a></li>
|
||
<li><a class="reference internal" href="#venv">venv</a></li>
|
||
<li><a class="reference internal" href="#warnings">warnings</a></li>
|
||
<li><a class="reference internal" href="#wave">wave</a></li>
|
||
<li><a class="reference internal" href="#webbrowser">webbrowser</a></li>
|
||
<li><a class="reference internal" href="#xml">xml</a></li>
|
||
<li><a class="reference internal" href="#xml-parsers-expat">xml.parsers.expat</a></li>
|
||
<li><a class="reference internal" href="#zlib">zlib</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#optimizations">Optimizations</a><ul>
|
||
<li><a class="reference internal" href="#base64-binascii">base64 & binascii</a></li>
|
||
<li><a class="reference internal" href="#csv">csv</a></li>
|
||
<li><a class="reference internal" href="#upgraded-experimental-jit-compiler">Upgraded experimental JIT compiler</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#removed">Removed</a><ul>
|
||
<li><a class="reference internal" href="#id1">ast</a></li>
|
||
<li><a class="reference internal" href="#collections-abc">collections.abc</a></li>
|
||
<li><a class="reference internal" href="#id2">ctypes</a></li>
|
||
<li><a class="reference internal" href="#datetime">datetime</a></li>
|
||
<li><a class="reference internal" href="#glob">glob</a></li>
|
||
<li><a class="reference internal" href="#id3">http.server</a></li>
|
||
<li><a class="reference internal" href="#importlib">importlib</a></li>
|
||
<li><a class="reference internal" href="#importlib-resources">importlib.resources</a></li>
|
||
<li><a class="reference internal" href="#id4">pathlib</a></li>
|
||
<li><a class="reference internal" href="#platform">platform</a></li>
|
||
<li><a class="reference internal" href="#sre">sre_*</a></li>
|
||
<li><a class="reference internal" href="#sysconfig">sysconfig</a></li>
|
||
<li><a class="reference internal" href="#id5">threading</a></li>
|
||
<li><a class="reference internal" href="#id6">types</a></li>
|
||
<li><a class="reference internal" href="#id7">typing</a></li>
|
||
<li><a class="reference internal" href="#id8">wave</a></li>
|
||
<li><a class="reference internal" href="#zipimport">zipimport</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#deprecated">Deprecated</a><ul>
|
||
<li><a class="reference internal" href="#new-deprecations">New deprecations</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-16">Pending removal in Python 3.16</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-17">Pending removal in Python 3.17</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-18">Pending removal in Python 3.18</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-19">Pending removal in Python 3.19</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-python-3-20">Pending removal in Python 3.20</a></li>
|
||
<li><a class="reference internal" href="#pending-removal-in-future-versions">Pending removal in future versions</a></li>
|
||
<li><a class="reference internal" href="#soft-deprecations">Soft deprecations</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#c-api-changes">C API changes</a><ul>
|
||
<li><a class="reference internal" href="#id9">New features</a></li>
|
||
<li><a class="reference internal" href="#changed-c-apis">Changed C APIs</a></li>
|
||
<li><a class="reference internal" href="#removed-c-apis">Removed C APIs</a></li>
|
||
<li><a class="reference internal" href="#deprecated-c-apis">Deprecated C APIs</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a class="reference internal" href="#build-changes">Build changes</a></li>
|
||
<li><a class="reference internal" href="#porting-to-python-3-15">Porting to Python 3.15</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
</div>
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="index.html"
|
||
title="previous chapter">What’s New in Python</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="3.14.html"
|
||
title="next chapter">What’s new in Python 3.14</a></p>
|
||
</div>
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
const title = document.querySelector('meta[property="og:title"]').content;
|
||
const elements = document.querySelectorAll('.improvepage');
|
||
const pageurl = window.location.href.split('?')[0];
|
||
elements.forEach(element => {
|
||
const url = new URL(element.href.split('?')[0].replace("-nojs", ""));
|
||
url.searchParams.set('pagetitle', title);
|
||
url.searchParams.set('pageurl', pageurl);
|
||
url.searchParams.set('pagesource', "whatsnew/3.15.rst");
|
||
element.href = url.toString();
|
||
});
|
||
});
|
||
</script>
|
||
<div role="note" aria-label="source link">
|
||
<h3>This page</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">Report a bug</a></li>
|
||
<li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.15/Doc/whatsnew/3.15.rst?plain=1"
|
||
rel="nofollow">Show source
|
||
</a>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div id="sidebarbutton" title="Collapse sidebar">
|
||
<span>«</span>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="3.14.html" title="What’s new in Python 3.14"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="index.html" title="What’s New in Python"
|
||
>previous</a> |</li>
|
||
|
||
<li class="root-icon"><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.15.0 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >What’s New in Python</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">What’s new in Python 3.15</a></li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">
|
||
<input type="submit" value="Go">
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
<li class="right">
|
||
<label class="theme-selector-label">
|
||
Theme
|
||
<select class="theme-selector" oninput="activateTheme(this.value)">
|
||
<option value="auto" selected>Auto</option>
|
||
<option value="light">Light</option>
|
||
<option value="dark">Dark</option>
|
||
</select>
|
||
</label> |</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.
|
||
<br>
|
||
This page is licensed under the Python Software Foundation License Version 2.
|
||
<br>
|
||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||
<br>
|
||
|
||
See <a href="/license.html">History and License</a> for more information.<br>
|
||
|
||
|
||
<br>
|
||
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br>
|
||
<br>
|
||
Last updated on Oct 09, 2026 (11:35 UTC).
|
||
|
||
<a href="/bugs.html">Found a bug</a>?
|
||
|
||
<br>
|
||
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |