summaryrefslogtreecommitdiff
path: root/Doc/library/dis.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r--Doc/library/dis.rst87
1 files changed, 73 insertions, 14 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 273fb20634..1bcb3a4a07 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -48,8 +48,9 @@ code.
.. class:: Bytecode(x, *, first_line=None, current_offset=None)
- Analyse the bytecode corresponding to a function, method, string of source
- code, or a code object (as returned by :func:`compile`).
+
+ Analyse the bytecode corresponding to a function, generator, method, string
+ of source code, or a code object (as returned by :func:`compile`).
This is a convenience wrapper around many of the functions listed below, most
notably :func:`get_instructions`, as iterating over a :class:`Bytecode`
@@ -109,7 +110,7 @@ operation is being performed, so the intermediate analysis object isn't useful:
.. function:: code_info(x)
Return a formatted multi-line string with detailed code object information
- for the supplied function, method, source code string or code object.
+ for the supplied function, generator, method, source code string or code object.
Note that the exact contents of code info strings are highly implementation
dependent and they may change arbitrarily across Python VMs or Python
@@ -136,11 +137,11 @@ operation is being performed, so the intermediate analysis object isn't useful:
.. function:: dis(x=None, *, file=None)
Disassemble the *x* object. *x* can denote either a module, a class, a
- method, a function, a code object, a string of source code or a byte sequence
- of raw bytecode. For a module, it disassembles all functions. For a class,
- it disassembles all methods. For a code object or sequence of raw bytecode,
- it prints one line per bytecode instruction. Strings are first compiled to
- code objects with the :func:`compile` built-in function before being
+ method, a function, a generator, a code object, a string of source code or
+ a byte sequence of raw bytecode. For a module, it disassembles all functions.
+ For a class, it disassembles all methods. For a code object or sequence of
+ raw bytecode, it prints one line per bytecode instruction. Strings are first
+ compiled to code objects with the :func:`compile` built-in function before being
disassembled. If no object is provided, this function disassembles the last
traceback.
@@ -345,6 +346,14 @@ result back on the stack.
Implements ``TOS = iter(TOS)``.
+.. opcode:: GET_YIELD_FROM_ITER
+
+ If ``TOS`` is a :term:`generator iterator` or :term:`coroutine` object
+ it is left as is. Otherwise, implements ``TOS = iter(TOS)``.
+
+ .. versionadded:: 3.5
+
+
**Binary operations**
Binary operations remove the top of the stack (TOS) and the second top-most
@@ -361,6 +370,13 @@ result back on the stack.
Implements ``TOS = TOS1 * TOS``.
+.. opcode:: BINARY_MATRIX_MULTIPLY
+
+ Implements ``TOS = TOS1 @ TOS``.
+
+ .. versionadded:: 3.5
+
+
.. opcode:: BINARY_FLOOR_DIVIDE
Implements ``TOS = TOS1 // TOS``.
@@ -433,6 +449,13 @@ the original TOS1.
Implements in-place ``TOS = TOS1 * TOS``.
+.. opcode:: INPLACE_MATRIX_MULTIPLY
+
+ Implements in-place ``TOS = TOS1 @ TOS``.
+
+ .. versionadded:: 3.5
+
+
.. opcode:: INPLACE_FLOOR_DIVIDE
Implements in-place ``TOS = TOS1 // TOS``.
@@ -493,6 +516,40 @@ the original TOS1.
Implements ``del TOS1[TOS]``.
+**Coroutine opcodes**
+
+.. opcode:: GET_AWAITABLE
+
+ Implements ``TOS = get_awaitable(TOS)``, where ``get_awaitable(o)``
+ returns ``o`` if ``o`` is a coroutine object or a generator object with
+ the CO_ITERABLE_COROUTINE flag, or resolves
+ ``o.__await__``.
+
+
+.. opcode:: GET_AITER
+
+ Implements ``TOS = get_awaitable(TOS.__aiter__())``. See ``GET_AWAITABLE``
+ for details about ``get_awaitable``
+
+
+.. opcode:: GET_ANEXT
+
+ Implements ``PUSH(get_awaitable(TOS.__anext__()))``. See ``GET_AWAITABLE``
+ for details about ``get_awaitable``
+
+
+.. opcode:: BEFORE_ASYNC_WITH
+
+ Resolves ``__aenter__`` and ``__aexit__`` from the object on top of the
+ stack. Pushes ``__aexit__`` and result of ``__aenter__()`` to the stack.
+
+
+.. opcode:: SETUP_ASYNC_WITH
+
+ Creates a new frame object.
+
+
+
**Miscellaneous opcodes**
.. opcode:: PRINT_EXPR
@@ -597,7 +654,7 @@ iterations of the loop.
:opcode:`UNPACK_SEQUENCE`).
-.. opcode:: WITH_CLEANUP
+.. opcode:: WITH_CLEANUP_START
Cleans up the stack when a :keyword:`with` statement block exits. TOS is the
context manager's :meth:`__exit__` bound method. Below TOS are 1--3 values
@@ -609,7 +666,13 @@ iterations of the loop.
* (SECOND, THIRD, FOURTH) = exc_info()
In the last case, ``TOS(SECOND, THIRD, FOURTH)`` is called, otherwise
- ``TOS(None, None, None)``. In addition, TOS is removed from the stack.
+ ``TOS(None, None, None)``. Pushes SECOND and result of the call
+ to the stack.
+
+
+.. opcode:: WITH_CLEANUP_FINISH
+
+ Pops exception type and result of 'exit' function call from the stack.
If the stack represents an exception, *and* the function call returns a
'true' value, this information is "zapped" and replaced with a single
@@ -795,10 +858,6 @@ the more significant byte last.
Pushes a try block from a try-except clause onto the block stack. *delta*
points to the finally block.
-.. opcode:: STORE_MAP
-
- Store a key and value pair in a dictionary. Pops the key and value while
- leaving the dictionary on the stack.
.. opcode:: LOAD_FAST (var_num)