CINXE.COM

PEP 3154 – Pickle protocol version 4 | 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 3154 – Pickle protocol version 4 | peps.python.org</title> <link rel="shortcut icon" href="../_static/py.png"> <link rel="canonical" href="https://peps.python.org/pep-3154/"> <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 3154 – Pickle protocol version 4 | peps.python.org'> <meta property="og:description" content="Data serialized using the pickle module must be portable across Python versions. It should also support the latest language features as well as implementation-specific features. For this reason, the pickle module knows about several protocols (current..."> <meta property="og:type" content="website"> <meta property="og:url" content="https://peps.python.org/pep-3154/"> <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="Data serialized using the pickle module must be portable across Python versions. It should also support the latest language features as well as implementation-specific features. For this reason, the pickle module knows about several protocols (current..."> <meta name="theme-color" content="#3776ab"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-sun-half" viewBox="0 0 24 24" pointer-events="all"> <title>Following system colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="9"></circle> <path d="M12 3v18m0-12l4.65-4.65M12 14.3l7.37-7.37M12 19.6l8.85-8.85"></path> </svg> </symbol> <symbol id="svg-moon" viewBox="0 0 24 24" pointer-events="all"> <title>Selected dark colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z"></path> </svg> </symbol> <symbol id="svg-sun" viewBox="0 0 24 24" pointer-events="all"> <title>Selected light colour scheme</title> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <circle cx="12" cy="12" r="5"></circle> <line x1="12" y1="1" x2="12" y2="3"></line> <line x1="12" y1="21" x2="12" y2="23"></line> <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line> <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line> <line x1="1" y1="12" x2="3" y2="12"></line> <line x1="21" y1="12" x2="23" y2="12"></line> <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line> <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line> </svg> </symbol> </svg> <script> document.documentElement.dataset.colour_scheme = localStorage.getItem("colour_scheme") || "auto" </script> <section id="pep-page-section"> <header> <h1>Python Enhancement Proposals</h1> <ul class="breadcrumbs"> <li><a href="https://www.python.org/" title="The Python Programming Language">Python</a> &raquo; </li> <li><a href="../pep-0000/">PEP Index</a> &raquo; </li> <li>PEP 3154</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 3154 – Pickle protocol version 4</h1> <dl class="rfc2822 field-list simple"> <dt class="field-odd">Author<span class="colon">:</span></dt> <dd class="field-odd">Antoine Pitrou &lt;solipsis&#32;&#97;t&#32;pitrou.net&gt;</dd> <dt class="field-even">Status<span class="colon">:</span></dt> <dd class="field-even"><abbr title="Accepted and implementation complete, or no longer active">Final</abbr></dd> <dt class="field-odd">Type<span class="colon">:</span></dt> <dd class="field-odd"><abbr title="Normative PEP with a new feature for Python, implementation change for CPython or interoperability standard for the ecosystem">Standards Track</abbr></dd> <dt class="field-even">Created<span class="colon">:</span></dt> <dd class="field-even">11-Aug-2011</dd> <dt class="field-odd">Python-Version<span class="colon">:</span></dt> <dd class="field-odd">3.4</dd> <dt class="field-even">Post-History<span class="colon">:</span></dt> <dd class="field-even"><a class="reference external" href="https://mail.python.org/pipermail/python-dev/2011-August/112821.html" title="Python-Dev message">12-Aug-2011</a></dd> <dt class="field-odd">Resolution<span class="colon">:</span></dt> <dd class="field-odd"><a class="reference external" href="https://mail.python.org/pipermail/python-dev/2013-November/130439.html">Python-Dev message</a></dd> </dl> <hr class="docutils" /> <section id="contents"> <details><summary>Table of Contents</summary><ul class="simple"> <li><a class="reference internal" href="#abstract">Abstract</a></li> <li><a class="reference internal" href="#rationale">Rationale</a></li> <li><a class="reference internal" href="#proposed-changes">Proposed changes</a><ul> <li><a class="reference internal" href="#framing">Framing</a></li> <li><a class="reference internal" href="#binary-encoding-for-all-opcodes">Binary encoding for all opcodes</a></li> <li><a class="reference internal" href="#serializing-more-lookupable-objects">Serializing more “lookupable” objects</a></li> <li><a class="reference internal" href="#bit-opcodes-for-large-objects">64-bit opcodes for large objects</a></li> <li><a class="reference internal" href="#native-opcodes-for-sets-and-frozensets">Native opcodes for sets and frozensets</a></li> <li><a class="reference internal" href="#calling-new-with-keyword-arguments">Calling __new__ with keyword arguments</a></li> <li><a class="reference internal" href="#better-string-encoding">Better string encoding</a></li> <li><a class="reference internal" href="#smaller-memoization">Smaller memoization</a></li> </ul> </li> <li><a class="reference internal" href="#summary-of-new-opcodes">Summary of new opcodes</a></li> <li><a class="reference internal" href="#alternative-ideas">Alternative ideas</a><ul> <li><a class="reference internal" href="#prefetching">Prefetching</a></li> </ul> </li> <li><a class="reference internal" href="#acknowledgments">Acknowledgments</a></li> <li><a class="reference internal" href="#references">References</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> </details></section> <section id="abstract"> <h2><a class="toc-backref" href="#abstract" role="doc-backlink">Abstract</a></h2> <p>Data serialized using the pickle module must be portable across Python versions. It should also support the latest language features as well as implementation-specific features. For this reason, the pickle module knows about several protocols (currently numbered from 0 to 3), each of which appeared in a different Python version. Using a low-numbered protocol version allows to exchange data with old Python versions, while using a high-numbered protocol allows access to newer features and sometimes more efficient resource use (both CPU time required for (de)serializing, and disk size / network bandwidth required for data transfer).</p> </section> <section id="rationale"> <h2><a class="toc-backref" href="#rationale" role="doc-backlink">Rationale</a></h2> <p>The latest current protocol, coincidentally named protocol 3, appeared with Python 3.0 and supports the new incompatible features in the language (mainly, unicode strings by default and the new bytes object). The opportunity was not taken at the time to improve the protocol in other ways.</p> <p>This PEP is an attempt to foster a number of incremental improvements in a new pickle protocol version. The PEP process is used in order to gather as many improvements as possible, because the introduction of a new pickle protocol should be a rare occurrence.</p> </section> <section id="proposed-changes"> <h2><a class="toc-backref" href="#proposed-changes" role="doc-backlink">Proposed changes</a></h2> <section id="framing"> <h3><a class="toc-backref" href="#framing" role="doc-backlink">Framing</a></h3> <p>Traditionally, when unpickling an object from a stream (by calling <code class="docutils literal notranslate"><span class="pre">load()</span></code> rather than <code class="docutils literal notranslate"><span class="pre">loads()</span></code>), many small <code class="docutils literal notranslate"><span class="pre">read()</span></code> calls can be issued on the file-like object, with a potentially huge performance impact.</p> <p>Protocol 4, by contrast, features binary framing. The general structure of a pickle is thus the following:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">+------+------+</span> <span class="o">|</span> <span class="mh">0x80</span> <span class="o">|</span> <span class="mh">0x04</span> <span class="o">|</span> <span class="n">protocol</span> <span class="n">header</span> <span class="p">(</span><span class="mi">2</span> <span class="nb">bytes</span><span class="p">)</span> <span class="o">+------+------+</span> <span class="o">|</span> <span class="n">OP</span> <span class="o">|</span> <span class="n">FRAME</span> <span class="n">opcode</span> <span class="p">(</span><span class="mi">1</span> <span class="n">byte</span><span class="p">)</span> <span class="o">+------+------+-----------+</span> <span class="o">|</span> <span class="n">MM</span> <span class="n">MM</span> <span class="n">MM</span> <span class="n">MM</span> <span class="n">MM</span> <span class="n">MM</span> <span class="n">MM</span> <span class="n">MM</span> <span class="o">|</span> <span class="n">frame</span> <span class="n">size</span> <span class="p">(</span><span class="mi">8</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">little</span><span class="o">-</span><span class="n">endian</span><span class="p">)</span> <span class="o">+------+------------------+</span> <span class="o">|</span> <span class="o">....</span> <span class="o">|</span> <span class="n">first</span> <span class="n">frame</span> <span class="n">contents</span> <span class="p">(</span><span class="n">M</span> <span class="nb">bytes</span><span class="p">)</span> <span class="o">+------+</span> <span class="o">|</span> <span class="n">OP</span> <span class="o">|</span> <span class="n">FRAME</span> <span class="n">opcode</span> <span class="p">(</span><span class="mi">1</span> <span class="n">byte</span><span class="p">)</span> <span class="o">+------+------+-----------+</span> <span class="o">|</span> <span class="n">NN</span> <span class="n">NN</span> <span class="n">NN</span> <span class="n">NN</span> <span class="n">NN</span> <span class="n">NN</span> <span class="n">NN</span> <span class="n">NN</span> <span class="o">|</span> <span class="n">frame</span> <span class="n">size</span> <span class="p">(</span><span class="mi">8</span> <span class="nb">bytes</span><span class="p">,</span> <span class="n">little</span><span class="o">-</span><span class="n">endian</span><span class="p">)</span> <span class="o">+------+------------------+</span> <span class="o">|</span> <span class="o">....</span> <span class="o">|</span> <span class="n">second</span> <span class="n">frame</span> <span class="n">contents</span> <span class="p">(</span><span class="n">N</span> <span class="nb">bytes</span><span class="p">)</span> <span class="o">+------+</span> <span class="n">etc</span><span class="o">.</span> </pre></div> </div> <p>To keep the implementation simple, it is forbidden for a pickle opcode to straddle frame boundaries. The pickler takes care not to produce such pickles, and the unpickler refuses them. Also, there is no “last frame” marker. The last frame is simply the one which ends with a STOP opcode.</p> <p>A well-written C implementation doesn’t need additional memory copies for the framing layer, preserving general (un)pickling efficiency.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>How the pickler decides to partition the pickle stream into frames is an implementation detail. For example, “closing” a frame as soon as it reaches ~64 KiB is a reasonable choice for both performance and pickle size overhead.</p> </div> </section> <section id="binary-encoding-for-all-opcodes"> <h3><a class="toc-backref" href="#binary-encoding-for-all-opcodes" role="doc-backlink">Binary encoding for all opcodes</a></h3> <p>The GLOBAL opcode, which is still used in protocol 3, uses the so-called “text” mode of the pickle protocol, which involves looking for newlines in the pickle stream. It also complicates the implementation of binary framing.</p> <p>Protocol 4 forbids use of the GLOBAL opcode and replaces it with STACK_GLOBAL, a new opcode which takes its operand from the stack.</p> </section> <section id="serializing-more-lookupable-objects"> <h3><a class="toc-backref" href="#serializing-more-lookupable-objects" role="doc-backlink">Serializing more “lookupable” objects</a></h3> <p>By default, pickle is only able to serialize module-global functions and classes. Supporting other kinds of objects, such as unbound methods <a class="footnote-reference brackets" href="#id12" id="id1">[4]</a>, is a common request. Actually, third-party support for some of them, such as bound methods, is implemented in the multiprocessing module <a class="footnote-reference brackets" href="#id13" id="id2">[5]</a>.</p> <p>The <code class="docutils literal notranslate"><span class="pre">__qualname__</span></code> attribute from <a class="pep reference internal" href="../pep-3155/" title="PEP 3155 – Qualified name for classes and functions">PEP 3155</a> makes it possible to lookup many more objects by name. Making the STACK_GLOBAL opcode accept dot-separated names would allow the standard pickle implementation to support all those kinds of objects.</p> </section> <section id="bit-opcodes-for-large-objects"> <h3><a class="toc-backref" href="#bit-opcodes-for-large-objects" role="doc-backlink">64-bit opcodes for large objects</a></h3> <p>Current protocol versions export object sizes for various built-in types (str, bytes) as 32-bit ints. This forbids serialization of large data <a class="footnote-reference brackets" href="#id9" id="id3">[1]</a>. New opcodes are required to support very large bytes and str objects.</p> </section> <section id="native-opcodes-for-sets-and-frozensets"> <h3><a class="toc-backref" href="#native-opcodes-for-sets-and-frozensets" role="doc-backlink">Native opcodes for sets and frozensets</a></h3> <p>Many common built-in types (such as str, bytes, dict, list, tuple) have dedicated opcodes to improve resource consumption when serializing and deserializing them; however, sets and frozensets don’t. Adding such opcodes would be an obvious improvement. Also, dedicated set support could help remove the current impossibility of pickling self-referential sets <a class="footnote-reference brackets" href="#id10" id="id4">[2]</a>.</p> </section> <section id="calling-new-with-keyword-arguments"> <h3><a class="toc-backref" href="#calling-new-with-keyword-arguments" role="doc-backlink">Calling __new__ with keyword arguments</a></h3> <p>Currently, classes whose <code class="docutils literal notranslate"><span class="pre">__new__</span></code> mandates the use of keyword-only arguments can not be pickled (or, rather, unpickled) <a class="footnote-reference brackets" href="#id11" id="id5">[3]</a>. Both a new special method (<code class="docutils literal notranslate"><span class="pre">__getnewargs_ex__</span></code>) and a new opcode (NEWOBJ_EX) are needed. The <code class="docutils literal notranslate"><span class="pre">__getnewargs_ex__</span></code> method, if it exists, must return a two-tuple <code class="docutils literal notranslate"><span class="pre">(args,</span> <span class="pre">kwargs)</span></code> where the first item is the tuple of positional arguments and the second item is the dict of keyword arguments for the class’s <code class="docutils literal notranslate"><span class="pre">__new__</span></code> method.</p> </section> <section id="better-string-encoding"> <h3><a class="toc-backref" href="#better-string-encoding" role="doc-backlink">Better string encoding</a></h3> <p>Short str objects currently have their length coded as a 4-bytes integer, which is wasteful. A specific opcode with a 1-byte length would make many pickles smaller.</p> </section> <section id="smaller-memoization"> <h3><a class="toc-backref" href="#smaller-memoization" role="doc-backlink">Smaller memoization</a></h3> <p>The PUT opcodes all require an explicit index to select in which entry of the memo dictionary the top-of-stack is memoized. However, in practice those numbers are allocated in sequential order. A new opcode, MEMOIZE, will instead store the top-of-stack in at the index equal to the current size of the memo dictionary. This allows for shorter pickles, since PUT opcodes are emitted for all non-atomic datatypes.</p> </section> </section> <section id="summary-of-new-opcodes"> <h2><a class="toc-backref" href="#summary-of-new-opcodes" role="doc-backlink">Summary of new opcodes</a></h2> <p>These reflect the state of the proposed implementation (thanks mostly to Alexandre Vassalotti’s work):</p> <ul class="simple"> <li><code class="docutils literal notranslate"><span class="pre">FRAME</span></code>: introduce a new frame (followed by the 8-byte frame size and the frame contents).</li> <li><code class="docutils literal notranslate"><span class="pre">SHORT_BINUNICODE</span></code>: push a utf8-encoded str object with a one-byte size prefix (therefore less than 256 bytes long).</li> <li><code class="docutils literal notranslate"><span class="pre">BINUNICODE8</span></code>: push a utf8-encoded str object with an eight-byte size prefix (for strings longer than 2**32 bytes, which therefore cannot be serialized using <code class="docutils literal notranslate"><span class="pre">BINUNICODE</span></code>).</li> <li><code class="docutils literal notranslate"><span class="pre">BINBYTES8</span></code>: push a bytes object with an eight-byte size prefix (for bytes objects longer than 2**32 bytes, which therefore cannot be serialized using <code class="docutils literal notranslate"><span class="pre">BINBYTES</span></code>).</li> <li><code class="docutils literal notranslate"><span class="pre">EMPTY_SET</span></code>: push a new empty set object on the stack.</li> <li><code class="docutils literal notranslate"><span class="pre">ADDITEMS</span></code>: add the topmost stack items to the set (to be used with <code class="docutils literal notranslate"><span class="pre">EMPTY_SET</span></code>).</li> <li><code class="docutils literal notranslate"><span class="pre">FROZENSET</span></code>: create a frozenset object from the topmost stack items, and push it on the stack.</li> <li><code class="docutils literal notranslate"><span class="pre">NEWOBJ_EX</span></code>: take the three topmost stack items <code class="docutils literal notranslate"><span class="pre">cls</span></code>, <code class="docutils literal notranslate"><span class="pre">args</span></code> and <code class="docutils literal notranslate"><span class="pre">kwargs</span></code>, and push the result of calling <code class="docutils literal notranslate"><span class="pre">cls.__new__(*args,</span> <span class="pre">**kwargs)</span></code>.</li> <li><code class="docutils literal notranslate"><span class="pre">STACK_GLOBAL</span></code>: take the two topmost stack items <code class="docutils literal notranslate"><span class="pre">module_name</span></code> and <code class="docutils literal notranslate"><span class="pre">qualname</span></code>, and push the result of looking up the dotted <code class="docutils literal notranslate"><span class="pre">qualname</span></code> in the module named <code class="docutils literal notranslate"><span class="pre">module_name</span></code>.</li> <li><code class="docutils literal notranslate"><span class="pre">MEMOIZE</span></code>: store the top-of-stack object in the memo dictionary with an index equal to the current size of the memo dictionary.</li> </ul> </section> <section id="alternative-ideas"> <h2><a class="toc-backref" href="#alternative-ideas" role="doc-backlink">Alternative ideas</a></h2> <section id="prefetching"> <h3><a class="toc-backref" href="#prefetching" role="doc-backlink">Prefetching</a></h3> <p>Serhiy Storchaka suggested to replace framing with a special PREFETCH opcode (with a 2- or 4-bytes argument) to declare known pickle chunks explicitly. Large data may be pickled outside such chunks. A naïve unpickler should be able to skip the PREFETCH opcode and still decode pickles properly, but good error handling would require checking that the PREFETCH length falls on an opcode boundary.</p> </section> </section> <section id="acknowledgments"> <h2><a class="toc-backref" href="#acknowledgments" role="doc-backlink">Acknowledgments</a></h2> <p>In alphabetic order:</p> <ul class="simple"> <li>Alexandre Vassalotti, for starting the second <a class="pep reference internal" href="../pep-3154/" title="PEP 3154 – Pickle protocol version 4">PEP 3154</a> implementation <a class="footnote-reference brackets" href="#id14" id="id6">[6]</a></li> <li>Serhiy Storchaka, for discussing the framing proposal <a class="footnote-reference brackets" href="#id14" id="id7">[6]</a></li> <li>Stefan Mihaila, for starting the first <a class="pep reference internal" href="../pep-3154/" title="PEP 3154 – Pickle protocol version 4">PEP 3154</a> implementation as a Google Summer of Code project mentored by Alexandre Vassalotti <a class="footnote-reference brackets" href="#id15" id="id8">[7]</a>.</li> </ul> </section> <section id="references"> <h2><a class="toc-backref" href="#references" role="doc-backlink">References</a></h2> <aside class="footnote-list brackets"> <aside class="footnote brackets" id="id9" role="doc-footnote"> <dt class="label" id="id9">[<a href="#id3">1</a>]</dt> <dd>“pickle not 64-bit ready”: <a class="reference external" href="http://bugs.python.org/issue11564">http://bugs.python.org/issue11564</a></aside> <aside class="footnote brackets" id="id10" role="doc-footnote"> <dt class="label" id="id10">[<a href="#id4">2</a>]</dt> <dd>“Cannot pickle self-referencing sets”: <a class="reference external" href="http://bugs.python.org/issue9269">http://bugs.python.org/issue9269</a></aside> <aside class="footnote brackets" id="id11" role="doc-footnote"> <dt class="label" id="id11">[<a href="#id5">3</a>]</dt> <dd>“pickle/copyreg doesn’t support keyword only arguments in __new__”: <a class="reference external" href="http://bugs.python.org/issue4727">http://bugs.python.org/issue4727</a></aside> <aside class="footnote brackets" id="id12" role="doc-footnote"> <dt class="label" id="id12">[<a href="#id1">4</a>]</dt> <dd>“pickle should support methods”: <a class="reference external" href="http://bugs.python.org/issue9276">http://bugs.python.org/issue9276</a></aside> <aside class="footnote brackets" id="id13" role="doc-footnote"> <dt class="label" id="id13">[<a href="#id2">5</a>]</dt> <dd>Lib/multiprocessing/forking.py: <a class="reference external" href="http://hg.python.org/cpython/file/baea9f5f973c/Lib/multiprocessing/forking.py#l54">http://hg.python.org/cpython/file/baea9f5f973c/Lib/multiprocessing/forking.py#l54</a></aside> <aside class="footnote brackets" id="id14" role="doc-footnote"> <dt class="label" id="id14">[6]<em> (<a href='#id6'>1</a>, <a href='#id7'>2</a>) </em></dt> <dd>Implement PEP 3154, by Alexandre Vassalotti <a class="reference external" href="http://bugs.python.org/issue17810">http://bugs.python.org/issue17810</a></aside> <aside class="footnote brackets" id="id15" role="doc-footnote"> <dt class="label" id="id15">[<a href="#id8">7</a>]</dt> <dd>Implement PEP 3154, by Stefan Mihaila <a class="reference external" href="http://bugs.python.org/issue15642">http://bugs.python.org/issue15642</a></aside> </aside> </section> <section id="copyright"> <h2><a class="toc-backref" href="#copyright" role="doc-backlink">Copyright</a></h2> <p>This document has been placed in the public domain.</p> </section> </section> <hr class="docutils" /> <p>Source: <a class="reference external" href="https://github.com/python/peps/blob/main/peps/pep-3154.rst">https://github.com/python/peps/blob/main/peps/pep-3154.rst</a></p> <p>Last modified: <a class="reference external" href="https://github.com/python/peps/commits/main/peps/pep-3154.rst">2025-02-01 08:59:27 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="#rationale">Rationale</a></li> <li><a class="reference internal" href="#proposed-changes">Proposed changes</a><ul> <li><a class="reference internal" href="#framing">Framing</a></li> <li><a class="reference internal" href="#binary-encoding-for-all-opcodes">Binary encoding for all opcodes</a></li> <li><a class="reference internal" href="#serializing-more-lookupable-objects">Serializing more “lookupable” objects</a></li> <li><a class="reference internal" href="#bit-opcodes-for-large-objects">64-bit opcodes for large objects</a></li> <li><a class="reference internal" href="#native-opcodes-for-sets-and-frozensets">Native opcodes for sets and frozensets</a></li> <li><a class="reference internal" href="#calling-new-with-keyword-arguments">Calling __new__ with keyword arguments</a></li> <li><a class="reference internal" href="#better-string-encoding">Better string encoding</a></li> <li><a class="reference internal" href="#smaller-memoization">Smaller memoization</a></li> </ul> </li> <li><a class="reference internal" href="#summary-of-new-opcodes">Summary of new opcodes</a></li> <li><a class="reference internal" href="#alternative-ideas">Alternative ideas</a><ul> <li><a class="reference internal" href="#prefetching">Prefetching</a></li> </ul> </li> <li><a class="reference internal" href="#acknowledgments">Acknowledgments</a></li> <li><a class="reference internal" href="#references">References</a></li> <li><a class="reference internal" href="#copyright">Copyright</a></li> </ul> <br> <a id="source" href="https://github.com/python/peps/blob/main/peps/pep-3154.rst">Page Source (GitHub)</a> </nav> </section> <script src="../_static/colour_scheme.js"></script> <script src="../_static/wrap_tables.js"></script> <script src="../_static/sticky_banner.js"></script> </body> </html>

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