Skip to content
94 changes: 7 additions & 87 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,23 +422,6 @@ 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``.


.. opcode:: BINARY_TRUE_DIVIDE

Implements ``TOS = TOS1 / TOS``.


.. opcode:: BINARY_MODULO

Implements ``TOS = TOS1 % TOS``.
Expand All @@ -449,41 +432,18 @@ result back on the stack.
Implements ``TOS = TOS1 + TOS``.


.. opcode:: BINARY_SUBTRACT
.. opcode:: BINARY_OP (op)

Implements ``TOS = TOS1 - TOS``.
Implements the remaining binary operators (depending on the value of *op*).

.. versionadded:: 3.11


.. opcode:: BINARY_SUBSCR

Implements ``TOS = TOS1[TOS]``.


.. opcode:: BINARY_LSHIFT

Implements ``TOS = TOS1 << TOS``.


.. opcode:: BINARY_RSHIFT

Implements ``TOS = TOS1 >> TOS``.


.. opcode:: BINARY_AND

Implements ``TOS = TOS1 & TOS``.


.. opcode:: BINARY_XOR

Implements ``TOS = TOS1 ^ TOS``.


.. opcode:: BINARY_OR

Implements ``TOS = TOS1 | TOS``.


**In-place operations**

In-place operations are like binary operations, in that they remove TOS and
Expand All @@ -501,23 +461,6 @@ 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``.


.. opcode:: INPLACE_TRUE_DIVIDE

Implements in-place ``TOS = TOS1 / TOS``.


.. opcode:: INPLACE_MODULO

Implements in-place ``TOS = TOS1 % TOS``.
Expand All @@ -528,34 +471,11 @@ the original TOS1.
Implements in-place ``TOS = TOS1 + TOS``.


.. opcode:: INPLACE_SUBTRACT

Implements in-place ``TOS = TOS1 - TOS``.

.. opcode:: INPLACE_OP (op)

.. opcode:: INPLACE_LSHIFT
Implements the remaining in-place operators (depending on the value of *op*).

Implements in-place ``TOS = TOS1 << TOS``.


.. opcode:: INPLACE_RSHIFT

Implements in-place ``TOS = TOS1 >> TOS``.


.. opcode:: INPLACE_AND

Implements in-place ``TOS = TOS1 & TOS``.


.. opcode:: INPLACE_XOR

Implements in-place ``TOS = TOS1 ^ TOS``.


.. opcode:: INPLACE_OR

Implements in-place ``TOS = TOS1 | TOS``.
.. versionadded:: 3.11


.. opcode:: STORE_SUBSCR
Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ Optimizations
CPython bytecode changes
========================

* Replaced most ``BINARY_*`` instructions with a single :opcode:`BINARY_OP`
implementation.

* Replaced most ``INPLACE_*`` instructions with a single :opcode:`INPLACE_OP`
implementation.

* Added a new :opcode:`CALL_METHOD_KW` opcode. Calls a method in a similar
fashion as :opcode:`CALL_METHOD`, but also supports keyword arguments. Works
in tandem with :opcode:`LOAD_METHOD`.
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ _PyIndex_Check(PyObject *obj)
return (tp_as_number != NULL && tp_as_number->nb_index != NULL);
}

PyObject *_PyNumber_Op(PyObject *o1, PyObject *o2, unsigned op);
PyObject *_PyNumber_InPlaceOp(PyObject *o1, PyObject *o2, unsigned op);

#ifdef __cplusplus
}
#endif
Expand Down
Loading