"dis" --- Python 字节码反汇编器
*******************************

**源代码:** Lib/dis.py

======================================================================

"dis" 模块通过反汇编支持CPython的 *bytecode* 分析。该模块作为输入的
CPython 字节码在文件 "Include/opcode.h" 中定义，并由编译器和解释器使用
。

**CPython 实现细节：** 字节码是 CPython 解释器的实现细节。不保证不会在
Python版本之间添加、删除或更改字节码。不应考虑将此模块的跨 Python VM
或 Python 版本的使用。

在 3.6 版本发生变更: 每条指令使用2个字节。以前字节数因指令而异。

在 3.10 版本发生变更: 跳转、异常处理和循环指令的参数现在将为指令偏移量
而不是字节偏移量。

在 3.11 版本发生变更: 有些指令带有一个或多个内联缓存条目，它们是采用
"CACHE" 指令的形式。 这些指令默认是隐藏的，但可以通过将
"show_caches=True" 传给任何 "dis" 工具对象来显示。 此外，解释器现在会
适配字节码以使其能针对不同的运行时条件实现专门化。 适配的字节码可通过
传入 "adaptive=True" 来显示。

示例：给出函数 "myfunc()":

   def myfunc(alist):
       return len(alist)

以下命令可被用来显示 "myfunc()" 的反汇编:

   >>> dis.dis(myfunc)
     2           0 RESUME                   0

     3           2 LOAD_GLOBAL              1 (NULL + len)
                14 LOAD_FAST                0 (alist)
                16 PRECALL                  1
                20 CALL                     1
                30 RETURN_VALUE

("2" 是行号)。


命令行接口
==========

"dis" 模块可以在命令行下作为一个脚本来唤起：

   python -m dis [-h] [-C] [infile]

可以接受以下选项：

-h, --help

   显示用法并退出。

-C, --show-caches

   Show inline caches.

如果指定了 "infile"，其反汇编代码将被写入到标准输出。 否则，反汇编将在
从标准输入接收的已编译源代码上进行。


字节码分析
==========

在 3.4 版本加入.

字节码分析 API 允许将 Python 代码片段包装在 "Bytecode" 对象中，以便轻
松访问已编译代码的详细信息。

class dis.Bytecode(x, *, first_line=None, current_offset=None, show_caches=False, adaptive=False)

   分析的字节码对应于函数、生成器、异步生成器、协程、方法、源代码字符
   串或代码对象（由 "compile()" 返回）。

   这是下面列出的许多函数的便利包装，最值得注意的是
   "get_instructions()" ，迭代于 "Bytecode" 的实例产生字节码操作
   "Instruction" 的实例。

   如果 *first_line* 不是 "None" ，则表示应该为反汇编代码中的第一个源
   代码行报告的行号。否则，源行信息（如果有的话）直接来自反汇编的代码
   对象。

   如果 *current_offset* 不是 "None" ，它指的就是汇编代码中的指令偏移
   量。设置它意味着 "dis()" 将针对指定的操作码显示“当前指令”标记。

   如果 *show_caches* 为 "True"，"dis()" 将显示解释器用来专门化字节码
   的内联缓存条目。

   如果 *adaptive* 为 "True"，"dis()" 将显示可能不同于原始字节码的专门
   化字节码。

   classmethod from_traceback(tb, *, show_caches=False)

      从给定回溯构造一个 "Bytecode" 实例，将设置 *current_offset* 为异
      常负责的指令。

   codeobj

      已编译的代码对象。

   first_line

      代码对象的第一个源代码行（如果可用）

   dis()

      返回字节码操作的格式化视图（与 "dis.dis()" 打印相同，但作为多行
      字符串返回）。

   info()

      返回带有关于代码对象的详细信息的格式化多行字符串，如
      "code_info()" 。

   在 3.7 版本发生变更: 现在可以处理协程和异步生成器对象。

   在 3.11 版本发生变更: 增加了 *show_caches* 和 *adaptive* 形参。

示例:

   >>> bytecode = dis.Bytecode(myfunc)
   >>> for instr in bytecode:
   ...     print(instr.opname)
   ...
   RESUME
   LOAD_GLOBAL
   LOAD_FAST
   PRECALL
   CALL
   RETURN_VALUE


分析函数
========

"dis" 模块还定义了以下分析函数，它们将输入直接转换为所需的输出。如果只
执行单个操作，它们可能很有用，因此中间分析对象没用：

dis.code_info(x)

   返回格式化的多行字符串，其包含详细代码对象信息的用于被提供的函数、
   生成器、异步生成器、协程、方法、源代码字符串或代码对象。

   请注意，代码信息字符串的确切内容是高度依赖于实现的，它们可能会在
   Python VM或Python版本中任意更改。

   在 3.2 版本加入.

   在 3.7 版本发生变更: 现在可以处理协程和异步生成器对象。

dis.show_code(x, *, file=None)

   将提供的函数、方法。源代码字符串或代码对象的详细代码对象信息打印到
   *file* （如果未指定 *file* ，则为 "sys.stdout" ）。

   这是 "print(code_info(x), file=file)" 的便捷简写，用于在解释器提示
   符下进行交互式探索。

   在 3.2 版本加入.

   在 3.4 版本发生变更: 添加 *file* 形参。

dis.dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False)

   Disassemble the *x* object.  *x* can denote either a module, a
   class, a method, a function, a generator, an asynchronous
   generator, a coroutine, 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 (including
   class and static methods). For a code object or sequence of raw
   bytecode, it prints one line per bytecode instruction. It also
   recursively disassembles nested code objects (the code of
   comprehensions, generator expressions and nested functions, and the
   code used for building nested classes). Strings are first compiled
   to code objects with the "compile()" built-in function before being
   disassembled.  If no object is provided, this function disassembles
   the last traceback.

   如果提供的话，反汇编将作为文本写入提供的 *file* 参数，否则写入
   "sys.stdout" 。

   递归的最大深度受 *depth* 限制，除非它是 "None" 。 "depth=0" 表示没
   有递归。

   如果 *show_caches* 为 "True"，此函数将显示解释器用来专门化字节码的
   内联缓存条目。

   如果 *adaptive* 为 "True"，此函数将显示可能不同于原始字节码的专门化
   字节码。

   在 3.4 版本发生变更: 添加 *file* 形参。

   在 3.7 版本发生变更: 实现了递归反汇编并添加了 *depth* 参数。

   在 3.7 版本发生变更: 现在可以处理协程和异步生成器对象。

   在 3.11 版本发生变更: 增加了 *show_caches* 和 *adaptive* 形参。

dis.distb(tb=None, *, file=None, show_caches=False, adaptive=False)

   如果没有传递，则使用最后一个回溯来反汇编回溯的堆栈顶部函数。 指示了
   导致异常的指令。

   如果提供的话，反汇编将作为文本写入提供的 *file* 参数，否则写入
   "sys.stdout" 。

   在 3.4 版本发生变更: 添加 *file* 形参。

   在 3.11 版本发生变更: 增加了 *show_caches* 和 *adaptive* 形参。

dis.disassemble(code, lasti=-1, *, file=None, show_caches=False, adaptive=False)
dis.disco(code, lasti=-1, *, file=None, show_caches=False, adaptive=False)

   反汇编代码对象，如果提供了 *lasti* ，则指示最后一条指令。输出分为以
   下几列：

   1. 行号，用于每行的第一条指令

   2. 当前指令，表示为 "-->" ，

   3. 一个标记的指令，用 ">>" 表示，

   4. 指令的地址，

   5. 操作码名称，

   6. 操作参数，和

   7. 括号中参数的解释。

   参数解释识别本地和全局变量名称、常量值、分支目标和比较运算符。

   如果提供的话，反汇编将作为文本写入提供的 *file* 参数，否则写入
   "sys.stdout" 。

   在 3.4 版本发生变更: 添加 *file* 形参。

   在 3.11 版本发生变更: 增加了 *show_caches* 和 *adaptive* 形参。

dis.get_instructions(x, *, first_line=None, show_caches=False, adaptive=False)

   在所提供的函数、方法、源代码字符串或代码对象中的指令上返回一个迭代
   器。

   迭代器生成一系列 "Instruction" ，命名为元组，提供所提供代码中每个操
   作的详细信息。

   如果 *first_line* 不是 "None" ，则表示应该为反汇编代码中的第一个源
   代码行报告的行号。否则，源行信息（如果有的话）直接来自反汇编的代码
   对象。

   *show_caches* 和 *adaptive* 形参的作用与 "dis()" 中的同名形参相同。

   在 3.4 版本加入.

   在 3.11 版本发生变更: 增加了 *show_caches* 和 *adaptive* 形参。

dis.findlinestarts(code)

   这个生成器函数使用 代码对象 *code* 的 "co_lines()" 方法来查找源代码
   中行开头的偏移量。 它们将作为 "(offset, lineno)" 对被生成。

   在 3.6 版本发生变更: 行号可能会减少。 以前，他们总是在增加。

   在 3.10 版本发生变更: 使用 **PEP 626** "co_lines()" 方法而不是 代码
   对象 的 "co_firstlineno" 和 "co_lnotab" 属性。

dis.findlabels(code)

   检测作为跳转目标的原始编译后字节码字符串 *code* 中的所有偏移量，并
   返回这些偏移量的列表。

dis.stack_effect(opcode, oparg=None, *, jump=None)

   使用参数 *oparg* 计算 *opcode* 的堆栈效果。

   如果代码有一个跳转目标并且 *jump* 是 "True" ，则 "drag_effect()" 将
   返回跳转的堆栈效果。如果 *jump* 是 "False" ，它将返回不跳跃的堆栈效
   果。如果 *jump* 是 "None" （默认值），它将返回两种情况的最大堆栈效
   果。

   在 3.4 版本加入.

   在 3.8 版本发生变更: 添加 *jump* 参数。


Python字节码说明
================

"get_instructions()" 函数和 "Bytecode" 类提供字节码指令的详细信息的
"Instruction" 实例：

class dis.Instruction

   字节码操作的详细信息

   opcode

      操作的数字代码，对应于下面列出的操作码值和 操作码集合 中的字节码
      值。

   opname

      人类可读的操作名称

   arg

      操作的数字参数（如果有的话），否则为 "None"

   argval

      已解析的 arg 值（如果有的话），否则为 "None"

   argrepr

      人类可读的操作参数（如果存在）的描述，否则为空字符串。

   offset

      在字节码序列中的起始操作索引

   starts_line

      行由此操作码（如果有）启动，否则为 "None"

   is_jump_target

      如果其他代码跳到这里，则为 "True" ，否则为 "False"

   positions

      "dis.Positions" 对象保存了这条指令所涵盖的起始和结束位置。

   在 3.4 版本加入.

   在 3.11 版本发生变更: 增加了 "positions" 字段。

class dis.Positions

   考虑到此信息不可用的情况，某些字段可能为 "None"。

   lineno

   end_lineno

   col_offset

   end_col_offset

   在 3.11 版本加入.

Python编译器当前生成以下字节码指令。

**一般指令**

NOP

   无操作代码。 被字节码优化器用作占位符，以及生成行追踪事件。

POP_TOP

   Removes the top-of-stack (TOS) item.

COPY(i)

   Push the *i*-th item to the top of the stack. The item is not
   removed from its original location.

   在 3.11 版本加入.

SWAP(i)

   Swap TOS with the item at position *i*.

   在 3.11 版本加入.

CACHE

   此操作码不是真正的指令，它被用来为解释器标记额外空间以便在字节码中
   直接缓存有用的数据。 它会被所有 "dis" 工具自动隐藏，但可以通过
   "show_caches=True" 来查看。

   从逻辑上说，此空间是之前的指令的组成部分。 许多操作码都预期带有固定
   数量的缓存，并会指示解释器在运行时跳过它们。

   被填充的缓存看起来可以像是任意的指令，因此在读取或修改包含快取数据
   的原始自适应字节码时应当非常小心。

   在 3.11 版本加入.

**一元操作**

一元操作获取堆栈顶部元素，应用操作，并将结果推回堆栈。

UNARY_POSITIVE

   实现 "TOS = +TOS"。

UNARY_NEGATIVE

   实现 "TOS = -TOS"。

UNARY_NOT

   实现 "TOS = not TOS"。

UNARY_INVERT

   实现 "TOS = ~TOS"。

GET_ITER

   实现 "TOS = iter(TOS)"。

GET_YIELD_FROM_ITER

   If "TOS" is a *generator iterator* or *coroutine* object it is left
   as is.  Otherwise, implements "TOS = iter(TOS)".

   在 3.5 版本加入.

**双目和原地操作**

Binary operations remove the top of the stack (TOS) and the second
top-most stack item (TOS1) from the stack.  They perform the
operation, and put the result back on the stack.

In-place operations are like binary operations, in that they remove
TOS and TOS1, and push the result back on the stack, but the operation
is done in-place when TOS1 supports it, and the resulting TOS may be
(but does not have to be) the original TOS1.

BINARY_OP(op)

   Implements the binary and in-place operators (depending on the
   value of *op*).

   在 3.11 版本加入.

BINARY_SUBSCR

   实现 "TOS = TOS1[TOS]"。

STORE_SUBSCR

   Implements "TOS1[TOS] = TOS2".

DELETE_SUBSCR

   Implements "del TOS1[TOS]".

**协程操作码**

GET_AWAITABLE(where)

   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__".

      如果 "where" 操作数为非零值，则表示指令所在的位置:

      * "1" After a call to "__aenter__"

      * "2" After a call to "__aexit__"

   在 3.5 版本加入.

   在 3.11 版本发生变更: 在之前版本中，该指令没有 oparg。

GET_AITER

   Implements "TOS = TOS.__aiter__()".

   在 3.5 版本加入.

   在 3.7 版本发生变更: 已经不再支持从 "__aiter__" 返回可等待对象。

GET_ANEXT

   Pushes "get_awaitable(TOS.__anext__())" to the stack.  See
   "GET_AWAITABLE" for details about "get_awaitable".

   在 3.5 版本加入.

END_ASYNC_FOR

   Terminates an "async for" loop.  Handles an exception raised when
   awaiting a next item. The stack contains the async iterable in TOS1
   and the raised exception in TOS. Both are popped. If the exception
   is not "StopAsyncIteration", it is re-raised.

   在 3.8 版本加入.

   在 3.11 版本发生变更: 栈中的异常表示形式现在将由一个而不是三个条目
   组成。

BEFORE_ASYNC_WITH

   Resolves "__aenter__" and "__aexit__" from the object on top of the
   stack.  Pushes "__aexit__" and result of "__aenter__()" to the
   stack.

   在 3.5 版本加入.

**其他操作码**

PRINT_EXPR

   Implements the expression statement for the interactive mode.  TOS
   is removed from the stack and printed.  In non-interactive mode, an
   expression statement is terminated with "POP_TOP".

SET_ADD(i)

   Calls "set.add(TOS1[-i], TOS)".  Used to implement set
   comprehensions.

LIST_APPEND(i)

   Calls "list.append(TOS1[-i], TOS)".  Used to implement list
   comprehensions.

MAP_ADD(i)

   Calls "dict.__setitem__(TOS1[-i], TOS1, TOS)".  Used to implement
   dict comprehensions.

   在 3.1 版本加入.

   在 3.8 版本发生变更: Map value is TOS and map key is TOS1. Before,
   those were reversed.

对于所有 "SET_ADD" 、 "LIST_APPEND" 和 "MAP_ADD" 指令，当弹出添加的值
或键值对时，容器对象保留在堆栈上，以便它可用于循环的进一步迭代。

RETURN_VALUE

   Returns with TOS to the caller of the function.

YIELD_VALUE

   Pops TOS and yields it from a *generator*.

SETUP_ANNOTATIONS

   检查 "__annotations__" 是否在 "locals()" 中定义，如果没有，它被设置
   为空 "dict" 。只有在类或模块体静态地包含 *variable annotations* 时
   才会发出此操作码。

   在 3.6 版本加入.

IMPORT_STAR

   Loads all symbols not starting with "'_'" directly from the module
   TOS to the local namespace. The module is popped after loading all
   names. This opcode implements "from module import *".

POP_EXCEPT

   从栈中弹出一个值，它将被用来恢复异常状态。

   在 3.11 版本发生变更: 栈中的异常表示形式现在将由一个而不是三个条目
   组成。

RERAISE

   重新引发当前位于栈顶的异常。 如果 oparg 为非零值，则从栈顶额外弹出
   一个值用来设置当前帧的 "f_lasti"。

   在 3.9 版本加入.

   在 3.11 版本发生变更: 栈中的异常表示形式现在将由一个而不是三个条目
   组成。

PUSH_EXC_INFO

   从栈中弹出一个值。 将当前异常推入栈顶。 将原先被弹出的值推回栈。 在
   异常处理器中使用。

   在 3.11 版本加入.

CHECK_EXC_MATCH

   Performs exception matching for "except". Tests whether the TOS1 is
   an exception matching TOS. Pops TOS and pushes the boolean result
   of the test.

   在 3.11 版本加入.

CHECK_EG_MATCH

   Performs exception matching for "except*". Applies "split(TOS)" on
   the exception group representing TOS1.

   在匹配的情况下，从栈中弹出两项并推入不匹配的子分组 (如完全匹配则为
   "None") 以及匹配的子分组。 当没有任何匹配时，则弹出一项 (匹配类型)
   并推入 "None"。

   在 3.11 版本加入.

PREP_RERAISE_STAR

   Combines the raised and reraised exceptions list from TOS, into an
   exception group to propagate from a try-except* block. Uses the
   original exception group from TOS1 to reconstruct the structure of
   reraised exceptions. Pops two items from the stack and pushes the
   exception to reraise or "None" if there isn't one.

   在 3.11 版本加入.

WITH_EXCEPT_START

   调用栈中 4 号位置上的函数并附带代表位于栈顶的异常的参数 (type, val,
   tb)。 用于在 "with" 语句内发生异常时实现调用
   "context_manager.__exit__(*exc_info())"。

   在 3.9 版本加入.

   在 3.11 版本发生变更: "__exit__" 函数位于栈的 4 号位而不是 7 号位。
   栈中的异常表示形式现在由一项而不是三项组成。

LOAD_ASSERTION_ERROR

   将 "AssertionError" 推入栈顶。 由 "assert" 语句使用。

   在 3.9 版本加入.

LOAD_BUILD_CLASS

   将 "builtins.__build_class__()" 推入栈。 之后它将会被调用来构造一个
   类。

BEFORE_WITH(delta)

   此操作码会在 with 代码块开始之前执行多个操作。 首先，它将从上下文管
   理器加载 "__exit__()" 并将其推入栈顶以供 "WITH_EXCEPT_START" 后续使
   用。 然后，将调用 "__enter__()"。 最后，将调用 "__enter__()" 方法的
   结果推入栈顶。

   在 3.11 版本加入.

GET_LEN

   Push "len(TOS)" onto the stack.

   在 3.10 版本加入.

MATCH_MAPPING

   If TOS is an instance of "collections.abc.Mapping" (or, more
   technically: if it has the "Py_TPFLAGS_MAPPING" flag set in its
   "tp_flags"), push "True" onto the stack.  Otherwise, push "False".

   在 3.10 版本加入.

MATCH_SEQUENCE

   If TOS is an instance of "collections.abc.Sequence" and is *not* an
   instance of "str"/"bytes"/"bytearray" (or, more technically: if it
   has the "Py_TPFLAGS_SEQUENCE" flag set in its "tp_flags"), push
   "True" onto the stack.  Otherwise, push "False".

   在 3.10 版本加入.

MATCH_KEYS

   TOS is a tuple of mapping keys, and TOS1 is the match subject.  If
   TOS1 contains all of the keys in TOS, push a "tuple" containing the
   corresponding values. Otherwise, push "None".

   在 3.10 版本加入.

   在 3.11 版本发生变更: 在之前的版本中，该指令还会推入一个表示成功
   ("True") 或失败 ("False") 的布尔值。

STORE_NAME(namei)

   Implements "name = TOS". *namei* is the index of *name* in the
   attribute "co_names" of the code object. The compiler tries to use
   "STORE_FAST" or "STORE_GLOBAL" if possible.

DELETE_NAME(namei)

   实现 "del name"，其中 *namei* 是 代码对象 的 "co_names" 属性的索引
   。

UNPACK_SEQUENCE(count)

   Unpacks TOS into *count* individual values, which are put onto the
   stack right-to-left.

UNPACK_EX(counts)

   Implements assignment with a starred target: Unpacks an iterable in
   TOS into individual values, where the total number of values can be
   smaller than the number of items in the iterable: one of the new
   values will be a list of all leftover items.

   The low byte of *counts* is the number of values before the list
   value, the high byte of *counts* the number of values after it.
   The resulting values are put onto the stack right-to-left.

STORE_ATTR(namei)

   Implements "TOS.name = TOS1", where *namei* is the index of name in
   "co_names".

DELETE_ATTR(namei)

   Implements "del TOS.name", using *namei* as index into "co_names"
   of the code object.

STORE_GLOBAL(namei)

   类似于 "STORE_NAME" 但会将 name 存储为全局变量。

DELETE_GLOBAL(namei)

   类似于 "DELETE_NAME" 但会删除一个全局变量。

LOAD_CONST(consti)

   将 "co_consts[consti]" 推入栈顶。

LOAD_NAME(namei)

   Pushes the value associated with "co_names[namei]" onto the stack.

BUILD_TUPLE(count)

   Creates a tuple consuming *count* items from the stack, and pushes
   the resulting tuple onto the stack.

BUILD_LIST(count)

   类似于 "BUILD_TUPLE" 但会创建一个列表。

BUILD_SET(count)

   类似于 "BUILD_TUPLE" 但会创建一个集合。

BUILD_MAP(count)

   Pushes a new dictionary object onto the stack.  Pops "2 * count"
   items so that the dictionary holds *count* entries: "{..., TOS3:
   TOS2, TOS1: TOS}".

   在 3.5 版本发生变更: 字典是根据栈中的项创建而不是创建一个预设大小包
   含 *count* 项的空字典。

BUILD_CONST_KEY_MAP(count)

   The version of "BUILD_MAP" specialized for constant keys. Pops the
   top element on the stack which contains a tuple of keys, then
   starting from "TOS1", pops *count* values to form values in the
   built dictionary.

   在 3.6 版本加入.

BUILD_STRING(count)

   拼接 *count* 个来自栈的字符串并将结果字符串推入栈顶。

   在 3.6 版本加入.

LIST_TO_TUPLE

   Pops a list from the stack and pushes a tuple containing the same
   values.

   在 3.9 版本加入.

LIST_EXTEND(i)

   Calls "list.extend(TOS1[-i], TOS)".  Used to build lists.

   在 3.9 版本加入.

SET_UPDATE(i)

   Calls "set.update(TOS1[-i], TOS)".  Used to build sets.

   在 3.9 版本加入.

DICT_UPDATE(i)

   Calls "dict.update(TOS1[-i], TOS)".  Used to build dicts.

   在 3.9 版本加入.

DICT_MERGE(i)

   类似于 "DICT_UPDATE" 但对于重复的键会引发异常。

   在 3.9 版本加入.

LOAD_ATTR(namei)

   Replaces TOS with "getattr(TOS, co_names[namei])".

COMPARE_OP(opname)

   执行布尔运算操作。 操作名称可在 "cmp_op[opname]" 中找到。

IS_OP(invert)

   执行 "is" 比较，或者如果 "invert" 为 1 则执行 "is not"。

   在 3.9 版本加入.

CONTAINS_OP(invert)

   执行 "in" 比较，或者如果 "invert" 为 1 则执行 "not in"。

   在 3.9 版本加入.

IMPORT_NAME(namei)

   Imports the module "co_names[namei]".  TOS and TOS1 are popped and
   provide the *fromlist* and *level* arguments of "__import__()".
   The module object is pushed onto the stack.  The current namespace
   is not affected: for a proper import statement, a subsequent
   "STORE_FAST" instruction modifies the namespace.

IMPORT_FROM(namei)

   Loads the attribute "co_names[namei]" from the module found in TOS.
   The resulting object is pushed onto the stack, to be subsequently
   stored by a "STORE_FAST" instruction.

JUMP_FORWARD(delta)

   将字节码计数器的值增加 *delta*。

JUMP_BACKWARD(delta)

   将字节码计数器减少 *delta*。 检查中断。

   在 3.11 版本加入.

JUMP_BACKWARD_NO_INTERRUPT(delta)

   将字节码计数器减少 *delta*。 不检查中断。

   在 3.11 版本加入.

POP_JUMP_FORWARD_IF_TRUE(delta)

   If TOS is true, increments the bytecode counter by *delta*.  TOS is
   popped.

   在 3.11 版本加入.

POP_JUMP_BACKWARD_IF_TRUE(delta)

   If TOS is true, decrements the bytecode counter by *delta*.  TOS is
   popped.

   在 3.11 版本加入.

POP_JUMP_FORWARD_IF_FALSE(delta)

   If TOS is false, increments the bytecode counter by *delta*.  TOS
   is popped.

   在 3.11 版本加入.

POP_JUMP_BACKWARD_IF_FALSE(delta)

   If TOS is false, decrements the bytecode counter by *delta*.  TOS
   is popped.

   在 3.11 版本加入.

POP_JUMP_FORWARD_IF_NOT_NONE(delta)

   If TOS is not "None", increments the bytecode counter by *delta*.
   TOS is popped.

   在 3.11 版本加入.

POP_JUMP_BACKWARD_IF_NOT_NONE(delta)

   If TOS is not "None", decrements the bytecode counter by *delta*.
   TOS is popped.

   在 3.11 版本加入.

POP_JUMP_FORWARD_IF_NONE(delta)

   If TOS is "None", increments the bytecode counter by *delta*.  TOS
   is popped.

   在 3.11 版本加入.

POP_JUMP_BACKWARD_IF_NONE(delta)

   If TOS is "None", decrements the bytecode counter by *delta*.  TOS
   is popped.

   在 3.11 版本加入.

JUMP_IF_TRUE_OR_POP(delta)

   If TOS is true, increments the bytecode counter by *delta* and
   leaves TOS on the stack.  Otherwise (TOS is false), TOS is popped.

   在 3.1 版本加入.

   在 3.11 版本发生变更: The oparg is now a relative delta rather than
   an absolute target.

JUMP_IF_FALSE_OR_POP(delta)

   If TOS is false, increments the bytecode counter by *delta* and
   leaves TOS on the stack.  Otherwise (TOS is true), TOS is popped.

   在 3.1 版本加入.

   在 3.11 版本发生变更: The oparg is now a relative delta rather than
   an absolute target.

FOR_ITER(delta)

   TOS is an *iterator*.  Call its "__next__()" method.  If this
   yields a new value, push it on the stack (leaving the iterator
   below it).  If the iterator indicates it is exhausted, TOS is
   popped, and the byte code counter is incremented by *delta*.

LOAD_GLOBAL(namei)

   将名为 "co_names[namei>>1]" 的全局对象加载到栈顶。

   在 3.11 版本发生变更: 如果设置了 "namei" 的低比特位，则会在全局变量
   前将一个 "NULL" 推入栈。

LOAD_FAST(var_num)

   将指向局部对象 "co_varnames[var_num]" 的引用推入栈顶。

STORE_FAST(var_num)

   Stores TOS into the local "co_varnames[var_num]".

DELETE_FAST(var_num)

   移除局部对象 "co_varnames[var_num]"。

MAKE_CELL(i)

   在槽位 "i" 中创建一个新单元。 如果该槽位为非空则该值将存储到新单元
   中。

   在 3.11 版本加入.

LOAD_CLOSURE(i)

   推入一个指向包含在 "fast locals" 存储的 "i" 号槽位的单元的引用。 变
   量名为 "co_fastlocalnames[i]"。

   注意 "LOAD_CLOSURE" 实际上是 "LOAD_FAST" 的一个别名。 它的存在是为
   了让字节码的可读性更好一些。

   在 3.11 版本发生变更: "i" 不再是长度为 "co_varnames" 的偏移量。

LOAD_DEREF(i)

   加载包含在 "fast locals" 存储的 "i" 号槽位中的单元。 将一个指向该单
   元所包含对象的引用推入栈。

   在 3.11 版本发生变更: "i" 不再是 "co_varnames" 的长度的偏移量。

LOAD_CLASSDEREF(i)

   Much like "LOAD_DEREF" but first checks the locals dictionary
   before consulting the cell.  This is used for loading free
   variables in class bodies.

   在 3.4 版本加入.

   在 3.11 版本发生变更: "i" 不再是长度为 "co_varnames" 的偏移量。

STORE_DEREF(i)

   Stores TOS into the cell contained in slot "i" of the "fast locals"
   storage.

   在 3.11 版本发生变更: "i" 不再是 "co_varnames" 的长度的偏移量。

DELETE_DEREF(i)

   清空 "fast locals" 存储中包含在 "i" 号槽位的单元。 被用于 "del" 语
   句。

   在 3.2 版本加入.

   在 3.11 版本发生变更: "i" 不再是 "co_varnames" 的长度的偏移量。

COPY_FREE_VARS(n)

   将 "n" 个自由变量从闭包拷贝到帧中。 当调用闭包时不再需要调用方添加
   特殊的代码。

   在 3.11 版本加入.

RAISE_VARARGS(argc)

   使用 "raise" 语句的 3 种形式之一引发异常，具体形式取决于 *argc* 的
   值：

   * 0: "raise" (重新引发之前的异常)

   * 1: "raise TOS" (raise exception instance or type at "TOS")

   * 2: "raise TOS1 from TOS" (raise exception instance or type at
     "TOS1" with "__cause__" set to "TOS")

CALL(argc)

   调用一个可调用对象并传入由 "argc" 所指定数量的参数，包括之前的
   "KW_NAMES" 所指定的关键字参数，如果有的话。 在栈上（按升序排列），
   可以是:

   * NULL

   * 可调用对象

   * 位置参数

   * 关键字参数

   或者:

   * 可调用对象

   * "self"

   * 其余的位置参数

   * 关键字参数

   "argc" 是位置和关键字参数的总和，当未提供 "NULL" 时将排除 "self"。

   "CALL" 将把所有参数和可调用对象弹出栈，附带这些参数调用该可调用对象
   ，并将该可调用对象的返回值推入栈。

   在 3.11 版本加入.

CALL_FUNCTION_EX(flags)

   调用一个可调用对象并附带位置参数和关键字参数变量集合。 如果设置了
   *flags* 的最低位，则栈顶包含一个由额外关键字参数组成的映射对象。 在
   调用该可调用对象之前，映射对象和可迭代对象会被分别“解包”并将它们的
   内容分别作为关键字参数和位置参数传入。 "CALL_FUNCTION_EX" 会中栈中
   弹出所有参数及可调用对象，附带这些参数调用该可调用对象，并将可调用
   对象所返回的返回值推入栈顶。

   在 3.6 版本加入.

LOAD_METHOD(namei)

   Loads a method named "co_names[namei]" from the TOS object. TOS is
   popped. This bytecode distinguishes two cases: if TOS has a method
   with the correct name, the bytecode pushes the unbound method and
   TOS. TOS will be used as the first argument ("self") by "CALL" when
   calling the unbound method. Otherwise, "NULL" and the object return
   by the attribute lookup are pushed.

   在 3.7 版本加入.

PRECALL(argc)

   Prefixes "CALL". Logically this is a no op. It exists to enable
   effective specialization of calls. "argc" is the number of
   arguments as described in "CALL".

   在 3.11 版本加入.

PUSH_NULL

      将一个 "NULL" 推入栈。 在调用序列中用来匹配 "LOAD_METHOD" 针对非
      方法调用推入栈的 "NULL"。

   在 3.11 版本加入.

KW_NAMES(i)

   Prefixes "PRECALL". Stores a reference to "co_consts[consti]" into
   an internal variable for use by "CALL". "co_consts[consti]" must be
   a tuple of strings.

   在 3.11 版本加入.

MAKE_FUNCTION(flags)

   将一个新函数对象推入栈顶。 从底端到顶端，如果参数带有指定的旗标值则
   所使用的栈必须由这些值组成。

   * "0x01" 一个默认值的元组，用于按位置排序的仅限位置形参以及位置或关
     键字形参

   * "0x02" 一个仅限关键字形参的默认值的字典

   * "0x04" 一个包含形参标注的字符串元组。

   * "0x08" 一个包含用于自由变量的单元的元组，生成一个闭包

   * the code associated with the function (at TOS)

   在 3.10 版本发生变更: 旗标值 "0x04" 是一个字符串元组而非字典。

   在 3.11 版本发生变更: Qualified name at TOS was removed.

BUILD_SLICE(argc)

   Pushes a slice object on the stack.  *argc* must be 2 or 3.  If it
   is 2, "slice(TOS1, TOS)" is pushed; if it is 3, "slice(TOS2, TOS1,
   TOS)" is pushed. See the "slice()" built-in function for more
   information.

EXTENDED_ARG(ext)

   为任意带有大到无法放入默认的单字节的参数的操作码添加前缀。 *ext* 存
   放一个附加字节作为参数中的高比特位。 对于每个操作码，最多允许三个
   "EXTENDED_ARG" 前缀，构成两字节到三字节的参数。

FORMAT_VALUE(flags)

   用于实现格式化字面值字符串（f-字符串）。 从栈中弹出一个可选的
   *fmt_spec*，然后是一个必须的 *value*。 *flags* 的解读方式如下：

   * "(flags & 0x03) == 0x00": *value* 按原样格式化。

   * "(flags & 0x03) == 0x01": 在格式化 *value* 之前调用其 "str()"。

   * "(flags & 0x03) == 0x02": 在格式化 *value* 之前调用其 "repr()"。

   * "(flags & 0x03) == 0x03": 在格式化 *value* 之前调用其 "ascii()"。

   * "(flags & 0x04) == 0x04": 从栈中弹出 *fmt_spec* 并使用它，否则使
     用空的 *fmt_spec*。

   使用 "PyObject_Format()" 执行格式化。 结果会被推入栈顶。

   在 3.6 版本加入.

MATCH_CLASS(count)

   TOS is a tuple of keyword attribute names, TOS1 is the class being
   matched against, and TOS2 is the match subject.  *count* is the
   number of positional sub-patterns.

   Pop TOS, TOS1, and TOS2.  If TOS2 is an instance of TOS1 and has
   the positional and keyword attributes required by *count* and TOS,
   push a tuple of extracted attributes.  Otherwise, push "None".

   在 3.10 版本加入.

   在 3.11 版本发生变更: 在之前的版本中，该指令还会推入一个表示成功
   ("True") 或失败 ("False") 的布尔值。

RESUME(where)

      空操作。 执行内部追踪、调试和优化检查。

      "where" 操作数标记 "RESUME" 在哪里发生:

      * "0" The start of a function

      * "1" 在 "yield" 表达式之后

      * "2" 在 "yield from" 表达式之后

      * "3" 在 "await" 表达式之后

   在 3.11 版本加入.

RETURN_GENERATOR

   Create a generator, coroutine, or async generator from the current
   frame. Clear the current frame and return the newly created
   generator.

   在 3.11 版本加入.

SEND

   Sends "None" to the sub-generator of this generator. Used in "yield
   from" and "await" statements.

   在 3.11 版本加入.

ASYNC_GEN_WRAP

   Wraps the value on top of the stack in an
   "async_generator_wrapped_value". Used to yield in async generators.

   在 3.11 版本加入.

HAVE_ARGUMENT

   这不是一个真正的操作码。 它标明了不使用参数和使用参数的操作码 (分别
   是 "< HAVE_ARGUMENT" 和 ">= HAVE_ARGUMENT") 之间的分隔线。

   在 3.6 版本发生变更: 现在每条指令都带有参数，但操作码 "<
   HAVE_ARGUMENT" 会忽略它。 之前仅限操作码 ">= HAVE_ARGUMENT" 带有参
   数。


操作码集合
==========

提供这些集合用于字节码指令的自动内省：

dis.opname

   操作名称的序列，可使用字节码来索引。

dis.opmap

   映射操作名称到字节码的字典

dis.cmp_op

   所有比较操作名称的序列。

dis.hasconst

   访问常量的字节码序列。

dis.hasfree

   Sequence of bytecodes that access a free variable (note that 'free'
   in this context refers to names in the current scope that are
   referenced by inner scopes or names in outer scopes that are
   referenced from this scope.  It does *not* include references to
   global or builtin scopes).

dis.hasname

   按名称访问属性的字节码序列。

dis.hasjrel

   具有相对跳转目标的字节码序列。

dis.hasjabs

   具有绝对跳转目标的字节码序列。

dis.haslocal

   访问局部变量的字节码序列。

dis.hascompare

   布尔运算的字节码序列。
