]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-90997: Document CACHEs (GH-95694)
authorBrandt Bucher <brandtbucher@gmail.com>
Fri, 5 Aug 2022 05:45:05 +0000 (22:45 -0700)
committerGitHub <noreply@github.com>
Fri, 5 Aug 2022 05:45:05 +0000 (22:45 -0700)
Doc/library/dis.rst
Doc/whatsnew/3.11.rst

index 68c3d1c0a4b24b0e0e0ca8ad1851f3ab47166774..63b064e7b444ecb2e8f75b16ea77ffaed50a1557 100644 (file)
@@ -408,6 +408,24 @@ The Python compiler currently generates the following bytecode instructions.
    .. versionadded:: 3.11
 
 
+.. opcode:: CACHE
+
+   Rather than being an actual instruction, this opcode is used to mark extra
+   space for the interpreter to cache useful data directly in the bytecode
+   itself. It is automatically hidden by all ``dis`` utilities, but can be
+   viewed with ``show_caches=True``.
+
+   Logically, this space is part of the preceding instruction. Many opcodes
+   expect to be followed by an exact number of caches, and will instruct the
+   interpreter to skip over them at runtime.
+
+   Populated caches can look like arbitrary instructions, so great care should
+   be taken when reading or modifying raw, adaptive bytecode containing
+   quickened data.
+
+   .. versionadded:: 3.11
+
+
 **Unary operations**
 
 Unary operations take the top of the stack, apply the operation, and push the
index c976eddb08ba0800a907dfda0173c73f5e8e3d32..f5d5d5f2be06a01e781b4cd702298ea9ebd9cf28 100644 (file)
@@ -1165,6 +1165,13 @@ contributors are volunteers from the community.
 CPython bytecode changes
 ========================
 
+* The bytecode now contains inline cache entries, which take the form of
+  :opcode:`CACHE` instructions. Many opcodes expect to be followed by an exact
+  number of caches, and instruct the interpreter to skip over them at runtime.
+  Populated caches can look like arbitrary instructions, so great care should be
+  taken when reading or modifying raw, adaptive bytecode containing quickened
+  data.
+
 * Replaced all numeric ``BINARY_*`` and ``INPLACE_*`` instructions with a single
   :opcode:`BINARY_OP` implementation.