bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)
Break up COMPARE_OP into four logically distinct opcodes:
* COMPARE_OP for rich comparisons
* IS_OP for 'is' and 'is not' tests
* CONTAINS_OP for 'in' and 'is not' tests
* JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 1f540d9..d3124f9 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -927,6 +927,20 @@
``cmp_op[opname]``.
+.. opcode:: IS_OP (invert)
+
+ Performs ``is`` comparison, or ``is not`` if ``invert`` is 1.
+
+ .. versionadded:: 3.9
+
+
+.. opcode:: CONTAINS_OP (invert)
+
+ Performs ``in`` comparison, or ``not in`` if ``invert`` is 1.
+
+ .. versionadded:: 3.9
+
+
.. opcode:: IMPORT_NAME (namei)
Imports the module ``co_names[namei]``. TOS and TOS1 are popped and provide
@@ -961,6 +975,13 @@
.. versionadded:: 3.1
+.. opcode:: JUMP_IF_NOT_EXC_MATCH (target)
+
+ Tests whether the second value on the stack is an exception matching TOS,
+ and jumps if it is not. Pops two values from the stack.
+
+ .. versionadded:: 3.9
+
.. opcode:: JUMP_IF_TRUE_OR_POP (target)