CINXE.COM
PEP 718 – Subscriptable functions | peps.python.org
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="color-scheme" content="light dark"> <title>PEP 718 – Subscriptable functions | peps.python.org</title> <link rel="shortcut icon" href="../_static/py.png"> <link rel="canonical" href="https://peps.python.org/pep-0718/"> <link rel="stylesheet" href="../_static/style.css" type="text/css"> <link rel="stylesheet" href="../_static/mq.css" type="text/css"> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" media="(prefers-color-scheme: light)" id="pyg-light"> <link rel="stylesheet" href="../_static/pygments_dark.css" type="text/css" media="(prefers-color-scheme: dark)" id="pyg-dark"> <link rel="alternate" type="application/rss+xml" title="Latest PEPs" href="https://peps.python.org/peps.rss"> <meta property="og:title" content='PEP 718 – Subscriptable functions | peps.python.org'> <meta property="og:description" content="This PEP proposes making function objects subscriptable for typing purposes. Doing so gives developers explicit control over the types produced by the type checker where bi-directional inference (which allows for the types of parameters of anonymous fun..."> <meta property="og:type" content="website"> <meta property="og:url" content="https://peps.python.org/pep-0718/"> <meta property="og:site_name" content="Python Enhancement Proposals (PEPs)"> <meta property="og:image" content="https://peps.python.org/_static/og-image.png"> <meta property="og:image:alt" content="Python PEPs"> <meta property="og:image:width" content="200"> <meta property="og:image:height" content="200"> <meta name="description" content="This PEP proposes making function objects subscriptable for typing purposes. Doing so gives developers explicit control over the types produced by the type checker where bi-directional inference (which allows for the types of parameters of anonymous fun..."> <meta name="theme-color" content="#3776ab"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-sun-half" viewBox="0 0 24 24" pointer-events="all"> <title>Following system colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="9"></circle> <path d="M12 3v18m0-12l4.65-4.65M12 14.3l7.37-7.37M12 19.6l8.85-8.85"></path> </svg> </symbol> <symbol id="svg-moon" viewBox="0 0 24 24" pointer-events="all"> <title>Selected dark colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z"></path> </svg> </symbol> <symbol id="svg-sun" viewBox="0 0 24 24" pointer-events="all"> <title>Selected light colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="5"></circle> <line x1="12" y1="1" x2="12" y2="3"></line> <line x1="12" y1="21" x2="12" y2="23"></line> <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line> <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line> <line x1="1" y1="12" x2="3" y2="12"></line> <line x1="21" y1="12" x2="23" y2="12"></line> <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line> <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line> </svg> </symbol> </svg> <script> document.documentElement.dataset.colour_scheme = localStorage.getItem("colour_scheme") || "auto" </script> <section id="pep-page-section"> <header> <h1>Python Enhancement Proposals</h1> <ul class="breadcrumbs"> <li><a href="https://www.python.org/" title="The Python Programming Language">Python</a> » </li> <li><a href="../pep-0000/">PEP Index</a> » </li> <li>PEP 718</li> </ul> <button id="colour-scheme-cycler" onClick="setColourScheme(nextColourScheme())"> <svg aria-hidden="true" class="colour-scheme-icon-when-auto"><use href="#svg-sun-half"></use></svg> <svg aria-hidden="true" class="colour-scheme-icon-when-dark"><use href="#svg-moon"></use></svg> <svg aria-hidden="true" class="colour-scheme-icon-when-light"><use href="#svg-sun"></use></svg> <span class="visually-hidden">Toggle light / dark / auto colour theme</span> </button> </header> <article> <section id="pep-content"> <h1 class="page-title">PEP 718 – Subscriptable functions</h1> <dl class="rfc2822 field-list simple"> <dt class="field-odd">Author<span class="colon">:</span></dt> <dd class="field-odd">James Hilton-Balfe <gobot1234yt at gmail.com></dd> <dt class="field-even">Sponsor<span class="colon">:</span></dt> <dd class="field-even">Guido van Rossum <guido at python.org></dd> <dt class="field-odd">Discussions-To<span class="colon">:</span></dt> <dd class="field-odd"><a class="reference external" href="https://discuss.python.org/t/28457/">Discourse thread</a></dd> <dt class="field-even">Status<span class="colon">:</span></dt> <dd class="field-even"><abbr title="Proposal under active discussion and revision">Draft</abbr></dd> <dt class="field-odd">Type<span class="colon">:</span></dt> <dd class="field-odd"><abbr title="Normative PEP with a new feature for Python, implementation change for CPython or interoperability standard for the ecosystem">Standards Track</abbr></dd> <dt class="field-even">Topic<span class="colon">:</span></dt> <dd class="field-even"><a class="reference external" href="../topic/typing/">Typing</a></dd> <dt class="field-odd">Created<span class="colon">:</span></dt> <dd class="field-odd">23-Jun-2023</dd> <dt class="field-even">Python-Version<span class="colon">:</span></dt> <dd class="field-even">3.13</dd> <dt class="field-odd">Post-History<span class="colon">:</span></dt> <dd class="field-odd"><a class="reference external" href="https://discuss.python.org/t/28457/" title="Discourse thread">24-Jun-2023</a></dd> </dl> <hr class="docutils" /> <section id="contents"> <details><summary>Table of Contents</summary><ul class="simple"> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#motivation">Motivation</a><ul> <li><a class="reference internal" href="#unknown-types">Unknown Types</a></li> <li><a class="reference internal" href="#undecidable-inference">Undecidable Inference</a></li> <li><a class="reference internal" href="#unsolvable-type-parameters">Unsolvable Type Parameters</a></li> <li><a class="reference internal" href="#monomorphisation-and-reification">Monomorphisation and Reification</a></li> </ul> </li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#specification">Specification</a><ul> <li><a class="reference internal" href="#setting-orig-class">Setting <code class="docutils literal notranslate"><span class="pre">__orig_class__</span></code></a></li> <li><a class="reference internal" href="#interactions-with-typing-overload">Interactions with <code class="docutils literal notranslate"><span class="pre">@typing.overload</span></code></a></li> </ul> </li> <li><a class="reference internal" href="#backwards-compatibility">Backwards Compatibility</a></li> <li><a class="reference internal" href="#reference-implementation">Reference Implementation</a></li> <li><a class="reference internal" href="#acknowledgements">Acknowledgements</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> </details></section> <section id="abstract"> <h2><a class="toc-backref" href="#abstract" role="doc-backlink">Abstract</a></h2> <p>This PEP proposes making function objects subscriptable for typing purposes. Doing so gives developers explicit control over the types produced by the type checker where bi-directional inference (which allows for the types of parameters of anonymous functions to be inferred) and other methods than specialisation are insufficient. It also brings functions in line with regular classes in their ability to be subscriptable.</p> </section> <section id="motivation"> <h2><a class="toc-backref" href="#motivation" role="doc-backlink">Motivation</a></h2> <section id="unknown-types"> <h3><a class="toc-backref" href="#unknown-types" role="doc-backlink">Unknown Types</a></h3> <p>Currently, it is not possible to infer the type parameters to generic functions in certain situations:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">make_list</span><span class="p">[</span><span class="n">T</span><span class="p">](</span><span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> <span class="o">...</span> <span class="n">reveal_type</span><span class="p">(</span><span class="n">make_list</span><span class="p">())</span> <span class="c1"># type checker cannot infer a meaningful type for T</span> </pre></div> </div> <p>Making instances of <code class="docutils literal notranslate"><span class="pre">FunctionType</span></code> subscriptable would allow for this constructor to be typed:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">reveal_type</span><span class="p">(</span><span class="n">make_list</span><span class="p">[</span><span class="nb">int</span><span class="p">]())</span> <span class="c1"># type is list[int]</span> </pre></div> </div> <p>Currently you have to use an assignment to provide a precise type:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">x</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="n">make_list</span><span class="p">()</span> <span class="n">reveal_type</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="c1"># type is list[int]</span> </pre></div> </div> <p>but this code is unnecessarily verbose taking up multiple lines for a simple function call.</p> <p>Similarly, <code class="docutils literal notranslate"><span class="pre">T</span></code> in this example cannot currently be meaningfully inferred, so <code class="docutils literal notranslate"><span class="pre">x</span></code> is untyped without an extra assignment:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">factory</span><span class="p">[</span><span class="n">T</span><span class="p">](</span><span class="n">func</span><span class="p">:</span> <span class="n">Callable</span><span class="p">[[</span><span class="n">T</span><span class="p">],</span> <span class="n">Any</span><span class="p">])</span> <span class="o">-></span> <span class="n">Foo</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> <span class="o">...</span> <span class="n">reveal_type</span><span class="p">(</span><span class="n">factory</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="s2">"Hello World"</span> <span class="o">*</span> <span class="n">x</span><span class="p">))</span> </pre></div> </div> <p>If function objects were subscriptable, however, a more specific type could be given:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">reveal_type</span><span class="p">(</span><span class="n">factory</span><span class="p">[</span><span class="nb">int</span><span class="p">](</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="s2">"Hello World"</span> <span class="o">*</span> <span class="n">x</span><span class="p">))</span> <span class="c1"># type is Foo[int]</span> </pre></div> </div> </section> <section id="undecidable-inference"> <h3><a class="toc-backref" href="#undecidable-inference" role="doc-backlink">Undecidable Inference</a></h3> <p>There are even cases where subclass relations make type inference impossible. However, if you can specialise the function type checkers can infer a meaningful type.</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">foo</span><span class="p">[</span><span class="n">T</span><span class="p">](</span><span class="n">x</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">T</span><span class="p">]</span> <span class="o">|</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> <span class="o">...</span> <span class="n">reveal_type</span><span class="p">(</span><span class="n">foo</span><span class="p">[</span><span class="nb">bytes</span><span class="p">](</span><span class="sa">b</span><span class="s2">"hello"</span><span class="p">))</span> </pre></div> </div> <p>Currently, type checkers do not consistently synthesise a type here.</p> </section> <section id="unsolvable-type-parameters"> <h3><a class="toc-backref" href="#unsolvable-type-parameters" role="doc-backlink">Unsolvable Type Parameters</a></h3> <p>Currently, with unspecialised literals, it is not possible to determine a type for situations similar to:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">foo</span><span class="p">[</span><span class="n">T</span><span class="p">](</span><span class="n">x</span><span class="p">:</span> <span class="nb">list</span><span class="p">[</span><span class="n">T</span><span class="p">])</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span> <span class="o">...</span> <span class="n">reveal_type</span><span class="p">(</span><span class="n">foo</span><span class="p">([]))</span> <span class="c1"># type checker cannot infer T (yet again)</span> </pre></div> </div> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">reveal_type</span><span class="p">(</span><span class="n">foo</span><span class="p">[</span><span class="nb">int</span><span class="p">]([]))</span> <span class="c1"># type is int</span> </pre></div> </div> <p>It is also useful to be able to specify in cases in which a certain type must be passed to a function beforehand:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">words</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"hello"</span><span class="p">,</span> <span class="s2">"world"</span><span class="p">]</span> <span class="n">foo</span><span class="p">[</span><span class="nb">int</span><span class="p">](</span><span class="n">words</span><span class="p">)</span> <span class="c1"># Invalid: list[str] is incompatible with list[int]</span> </pre></div> </div> <p>Allowing subscription makes functions and methods consistent with generic classes where they weren’t already. Whilst all of the proposed changes can be implemented using callable generic classes, syntactic sugar would be highly welcome.</p> <p>Due to this, specialising the function and using it as a new factory is fine</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">make_int_list</span> <span class="o">=</span> <span class="n">make_list</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="n">reveal_type</span><span class="p">(</span><span class="n">make_int_list</span><span class="p">())</span> <span class="c1"># type is list[int]</span> </pre></div> </div> </section> <section id="monomorphisation-and-reification"> <h3><a class="toc-backref" href="#monomorphisation-and-reification" role="doc-backlink">Monomorphisation and Reification</a></h3> <p>This proposal also opens the door to <a class="reference external" href="https://en.wikipedia.org/wiki/Monomorphization">monomorphisation</a> and <a class="reference external" href="https://en.wikipedia.org/wiki/Reification_(computer_science)">reified types</a>.</p> <p>This would allow for a functionality which anecdotally has been requested many times.</p> <p><em>Please note this feature is not being proposed by the PEP, but may be implemented in the future.</em></p> <p>The syntax for such a feature may look something like:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">foo</span><span class="p">[</span><span class="n">T</span><span class="p">]():</span> <span class="k">return</span> <span class="n">T</span><span class="o">.</span><span class="n">__value__</span> <span class="k">assert</span> <span class="n">foo</span><span class="p">[</span><span class="nb">int</span><span class="p">]()</span> <span class="ow">is</span> <span class="nb">int</span> </pre></div> </div> </section> </section> <section id="rationale"> <h2><a class="toc-backref" href="#rationale" role="doc-backlink">Rationale</a></h2> <p>Function objects in this PEP is used to refer to <code class="docutils literal notranslate"><span class="pre">FunctionType</span></code>, <code class="docutils literal notranslate"><span class="pre">MethodType</span></code>, <code class="docutils literal notranslate"><span class="pre">BuiltinFunctionType</span></code>, <code class="docutils literal notranslate"><span class="pre">BuiltinMethodType</span></code> and <code class="docutils literal notranslate"><span class="pre">MethodWrapperType</span></code>.</p> <p>For <code class="docutils literal notranslate"><span class="pre">MethodType</span></code> you should be able to write:</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">Foo</span><span class="p">:</span> <span class="k">def</span><span class="w"> </span><span class="nf">make_list</span><span class="p">[</span><span class="n">T</span><span class="p">](</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">T</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> <span class="o">...</span> <span class="n">Foo</span><span class="p">()</span><span class="o">.</span><span class="n">make_list</span><span class="p">[</span><span class="nb">int</span><span class="p">]()</span> </pre></div> </div> <p>and have it work similarly to a <code class="docutils literal notranslate"><span class="pre">FunctionType</span></code>.</p> <p>For <code class="docutils literal notranslate"><span class="pre">BuiltinFunctionType</span></code>, so builtin generic functions (e.g. <code class="docutils literal notranslate"><span class="pre">max</span></code> and <code class="docutils literal notranslate"><span class="pre">min</span></code>) work like ones defined in Python. Built-in functions should behave as much like functions implemented in Python as possible.</p> <p><code class="docutils literal notranslate"><span class="pre">BuiltinMethodType</span></code> is the same type as <code class="docutils literal notranslate"><span class="pre">BuiltinFunctionType</span></code>.</p> <p><code class="docutils literal notranslate"><span class="pre">MethodWrapperType</span></code> (e.g. the type of <code class="docutils literal notranslate"><span class="pre">object().__str__</span></code>) is useful for generic magic methods.</p> </section> <section id="specification"> <h2><a class="toc-backref" href="#specification" role="doc-backlink">Specification</a></h2> <p>Function objects should implement <code class="docutils literal notranslate"><span class="pre">__getitem__</span></code> to allow for subscription at runtime and return an instance of <code class="docutils literal notranslate"><span class="pre">types.GenericAlias</span></code> with <code class="docutils literal notranslate"><span class="pre">__origin__</span></code> set as the callable and <code class="docutils literal notranslate"><span class="pre">__args__</span></code> as the types passed.</p> <p>Type checkers should support subscripting functions and understand that the parameters passed to the function subscription should follow the same rules as a generic callable class.</p> <section id="setting-orig-class"> <h3><a class="toc-backref" href="#setting-orig-class" role="doc-backlink">Setting <code class="docutils literal notranslate"><span class="pre">__orig_class__</span></code></a></h3> <p>Currently, <code class="docutils literal notranslate"><span class="pre">__orig_class__</span></code> is an attribute set in <code class="docutils literal notranslate"><span class="pre">GenericAlias.__call__</span></code> to the instance of the <code class="docutils literal notranslate"><span class="pre">GenericAlias</span></code> that created the called class e.g.</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span><span class="w"> </span><span class="nc">Foo</span><span class="p">[</span><span class="n">T</span><span class="p">]:</span> <span class="o">...</span> <span class="k">assert</span> <span class="n">Foo</span><span class="p">[</span><span class="nb">int</span><span class="p">]()</span><span class="o">.</span><span class="n">__orig_class__</span> <span class="o">==</span> <span class="n">Foo</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> </pre></div> </div> <p>Currently, <code class="docutils literal notranslate"><span class="pre">__orig_class__</span></code> is unconditionally set; however, to avoid potential erasure on any created instances, this attribute should not be set if <code class="docutils literal notranslate"><span class="pre">__origin__</span></code> is an instance of any function object.</p> <p>The following code snippet would fail at runtime without this change as <code class="docutils literal notranslate"><span class="pre">__orig_class__</span></code> would be <code class="docutils literal notranslate"><span class="pre">bar[str]</span></code> and not <code class="docutils literal notranslate"><span class="pre">Foo[int]</span></code>.</p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span><span class="w"> </span><span class="nf">bar</span><span class="p">[</span><span class="n">U</span><span class="p">]():</span> <span class="k">return</span> <span class="n">Foo</span><span class="p">[</span><span class="nb">int</span><span class="p">]()</span> <span class="k">assert</span> <span class="n">bar</span><span class="p">[</span><span class="nb">str</span><span class="p">]()</span><span class="o">.</span><span class="n">__orig_class__</span> <span class="o">==</span> <span class="n">Foo</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> </pre></div> </div> </section> <section id="interactions-with-typing-overload"> <h3><a class="toc-backref" href="#interactions-with-typing-overload" role="doc-backlink">Interactions with <code class="docutils literal notranslate"><span class="pre">@typing.overload</span></code></a></h3> <p>Overloaded functions should work much the same as already, since they have no effect on the runtime type. The only change is that more situations will be decidable and the behaviour/overload can be specified by the developer rather than leaving it to ordering of overloads/unions.</p> </section> </section> <section id="backwards-compatibility"> <h2><a class="toc-backref" href="#backwards-compatibility" role="doc-backlink">Backwards Compatibility</a></h2> <p>Currently these classes are not subclassable and so there are no backwards compatibility concerns with regards to classes already implementing <code class="docutils literal notranslate"><span class="pre">__getitem__</span></code>.</p> </section> <section id="reference-implementation"> <h2><a class="toc-backref" href="#reference-implementation" role="doc-backlink">Reference Implementation</a></h2> <p>The runtime changes proposed can be found here <a class="reference external" href="https://github.com/Gobot1234/cpython/tree/function-subscript">https://github.com/Gobot1234/cpython/tree/function-subscript</a></p> </section> <section id="acknowledgements"> <h2><a class="toc-backref" href="#acknowledgements" role="doc-backlink">Acknowledgements</a></h2> <p>Thank you to Alex Waygood and Jelle Zijlstra for their feedback on this PEP and Guido for some motivating examples.</p> </section> <section id="copyright"> <h2><a class="toc-backref" href="#copyright" role="doc-backlink">Copyright</a></h2> <p>This document is placed in the public domain or under the CC0-1.0-Universal license, whichever is more permissive.</p> </section> </section> <hr class="docutils" /> <p>Source: <a class="reference external" href="https://github.com/python/peps/blob/main/peps/pep-0718.rst">https://github.com/python/peps/blob/main/peps/pep-0718.rst</a></p> <p>Last modified: <a class="reference external" href="https://github.com/python/peps/commits/main/peps/pep-0718.rst">2025-02-01 08:55:40 GMT</a></p> </article> <nav id="pep-sidebar"> <h2>Contents</h2> <ul> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#motivation">Motivation</a><ul> <li><a class="reference internal" href="#unknown-types">Unknown Types</a></li> <li><a class="reference internal" href="#undecidable-inference">Undecidable Inference</a></li> <li><a class="reference internal" href="#unsolvable-type-parameters">Unsolvable Type Parameters</a></li> <li><a class="reference internal" href="#monomorphisation-and-reification">Monomorphisation and Reification</a></li> </ul> </li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#specification">Specification</a><ul> <li><a class="reference internal" href="#setting-orig-class">Setting <code class="docutils literal notranslate"><span class="pre">__orig_class__</span></code></a></li> <li><a class="reference internal" href="#interactions-with-typing-overload">Interactions with <code class="docutils literal notranslate"><span class="pre">@typing.overload</span></code></a></li> </ul> </li> <li><a class="reference internal" href="#backwards-compatibility">Backwards Compatibility</a></li> <li><a class="reference internal" href="#reference-implementation">Reference Implementation</a></li> <li><a class="reference internal" href="#acknowledgements">Acknowledgements</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> <br> <a id="source" href="https://github.com/python/peps/blob/main/peps/pep-0718.rst">Page Source (GitHub)</a> </nav> </section> <script src="../_static/colour_scheme.js"></script> <script src="../_static/wrap_tables.js"></script> <script src="../_static/sticky_banner.js"></script> </body> </html>