Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22739a0

Browse filesBrowse files
authored
pythongh-95913: Edit, expand & format Bytecode sect in 3.11 WhatsNew (pythonGH-98559)
1 parent e81fad6 commit 22739a0
Copy full SHA for 22739a0

File tree

Expand file treeCollapse file tree

1 file changed

+81
-39
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+81
-39
lines changed

‎Doc/whatsnew/3.11.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.11.rst
+81-39Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,58 +1481,100 @@ contributors are volunteers from the community.
14811481
CPython bytecode changes
14821482
========================
14831483

1484-
* The bytecode now contains inline cache entries, which take the form of
1485-
:opcode:`CACHE` instructions. Many opcodes expect to be followed by an exact
1486-
number of caches, and instruct the interpreter to skip over them at runtime.
1487-
Populated caches can look like arbitrary instructions, so great care should be
1488-
taken when reading or modifying raw, adaptive bytecode containing quickened
1489-
data.
1484+
The bytecode now contains inline cache entries,
1485+
which take the form of the newly-added :opcode:`CACHE` instructions.
1486+
Many opcodes expect to be followed by an exact number of caches,
1487+
and instruct the interpreter to skip over them at runtime.
1488+
Populated caches can look like arbitrary instructions,
1489+
so great care should be taken when reading or modifying
1490+
raw, adaptive bytecode containing quickened data.
14901491

1491-
* Replaced all numeric ``BINARY_*`` and ``INPLACE_*`` instructions with a single
1492-
:opcode:`BINARY_OP` implementation.
14931492

1494-
* Replaced the three call instructions: :opcode:`CALL_FUNCTION`,
1495-
:opcode:`CALL_FUNCTION_KW` and :opcode:`CALL_METHOD` with
1496-
:opcode:`PUSH_NULL`, :opcode:`PRECALL`, :opcode:`CALL`,
1497-
and :opcode:`KW_NAMES`.
1498-
This decouples the argument shifting for methods from the handling of
1499-
keyword arguments and allows better specialization of calls.
1493+
.. _whatsnew311-added-opcodes:
15001494

1501-
* Removed ``COPY_DICT_WITHOUT_KEYS`` and ``GEN_START``.
1495+
New opcodes
1496+
-----------
1497+
1498+
* :opcode:`ASYNC_GEN_WRAP`, :opcode:`RETURN_GENERATOR` and :opcode:`SEND`,
1499+
used in generators and co-routines.
15021500

1503-
* :opcode:`MATCH_CLASS` and :opcode:`MATCH_KEYS` no longer push an additional
1504-
boolean value indicating whether the match succeeded or failed. Instead, they
1505-
indicate failure with :const:`None` (where a tuple of extracted values would
1506-
otherwise be).
1501+
* :opcode:`COPY_FREE_VARS`,
1502+
which avoids needing special caller-side code for closures.
15071503

1508-
* Replace several stack manipulation instructions (``DUP_TOP``, ``DUP_TOP_TWO``,
1509-
``ROT_TWO``, ``ROT_THREE``, ``ROT_FOUR``, and ``ROT_N``) with new
1510-
:opcode:`COPY` and :opcode:`SWAP` instructions.
1504+
* :opcode:`JUMP_BACKWARD_NO_INTERRUPT`,
1505+
for use in certain loops where handling interrupts is undesirable.
15111506

1512-
* Replaced :opcode:`JUMP_IF_NOT_EXC_MATCH` by :opcode:`CHECK_EXC_MATCH` which
1513-
performs the check but does not jump.
1507+
* :opcode:`MAKE_CELL`, to create :ref:`cell-objects`.
15141508

1515-
* Replaced :opcode:`JUMP_IF_NOT_EG_MATCH` by :opcode:`CHECK_EG_MATCH` which
1516-
performs the check but does not jump.
1509+
* :opcode:`CHECK_EG_MATCH` and :opcode:`PREP_RERAISE_STAR`,
1510+
to handle the :ref:`new exception groups and except* <whatsnew311-pep654>`
1511+
added in :pep:`654`.
15171512

1518-
* Replaced :opcode:`JUMP_ABSOLUTE` by the relative :opcode:`JUMP_BACKWARD`.
1513+
* :opcode:`PUSH_EXC_INFO`, for use in exception handlers.
15191514

1520-
* Added :opcode:`JUMP_BACKWARD_NO_INTERRUPT`, which is used in certain loops where it
1521-
is undesirable to handle interrupts.
1515+
* :opcode:`RESUME`, a no-op,
1516+
for internal tracing, debugging and optimization checks.
15221517

1523-
* Replaced :opcode:`POP_JUMP_IF_TRUE` and :opcode:`POP_JUMP_IF_FALSE` by
1524-
the relative :opcode:`POP_JUMP_FORWARD_IF_TRUE`, :opcode:`POP_JUMP_BACKWARD_IF_TRUE`,
1525-
:opcode:`POP_JUMP_FORWARD_IF_FALSE` and :opcode:`POP_JUMP_BACKWARD_IF_FALSE`.
15261518

1527-
* Added :opcode:`POP_JUMP_FORWARD_IF_NOT_NONE`, :opcode:`POP_JUMP_BACKWARD_IF_NOT_NONE`,
1528-
:opcode:`POP_JUMP_FORWARD_IF_NONE` and :opcode:`POP_JUMP_BACKWARD_IF_NONE`
1529-
opcodes to speed up conditional jumps.
1519+
.. _whatsnew311-replaced-opcodes:
15301520

1531-
* :opcode:`JUMP_IF_TRUE_OR_POP` and :opcode:`JUMP_IF_FALSE_OR_POP` are now
1532-
relative rather than absolute.
1521+
Replaced opcodes
1522+
----------------
15331523

1534-
* :opcode:`RESUME` has been added. It is a no-op. Performs internal tracing,
1535-
debugging and optimization checks.
1524+
+------------------------------------+-----------------------------------+-----------------------------------------+
1525+
| Replaced Opcode(s) | New Opcode(s) | Notes |
1526+
+====================================+===================================+=========================================+
1527+
| | :opcode:`!BINARY_*` | :opcode:`BINARY_OP` | Replaced all numeric binary/in-place |
1528+
| | :opcode:`!INPLACE_*` | | opcodes with a single opcode |
1529+
+------------------------------------+-----------------------------------+-----------------------------------------+
1530+
| | :opcode:`!CALL_FUNCTION` | | :opcode:`CALL` | Decouples argument shifting for methods |
1531+
| | :opcode:`!CALL_FUNCTION_KW` | | :opcode:`KW_NAMES` | from handling of keyword arguments; |
1532+
| | :opcode:`!CALL_METHOD` | | :opcode:`PRECALL` | allows better specialization of calls |
1533+
| | | :opcode:`PUSH_NULL` | |
1534+
+------------------------------------+-----------------------------------+-----------------------------------------+
1535+
| | :opcode:`!DUP_TOP` | | :opcode:`COPY` | Stack manipulation instructions |
1536+
| | :opcode:`!DUP_TOP_TWO` | | :opcode:`SWAP` | |
1537+
| | :opcode:`!ROT_TWO` | | |
1538+
| | :opcode:`!ROT_THREE` | | |
1539+
| | :opcode:`!ROT_FOUR` | | |
1540+
| | :opcode:`!ROT_N` | | |
1541+
+------------------------------------+-----------------------------------+-----------------------------------------+
1542+
| | :opcode:`!JUMP_IF_NOT_EXC_MATCH` | | :opcode:`CHECK_EXC_MATCH` | Now performs check but doesn't jump |
1543+
+------------------------------------+-----------------------------------+-----------------------------------------+
1544+
| | :opcode:`!JUMP_ABSOLUTE` | | :opcode:`JUMP_BACKWARD` | See [#bytecode-jump]_; |
1545+
| | :opcode:`!POP_JUMP_IF_FALSE` | | :opcode:`POP_JUMP_BACKWARD_IF_* | ``TRUE``, ``FALSE``, |
1546+
| | :opcode:`!POP_JUMP_IF_TRUE` | <POP_JUMP_BACKWARD_IF_TRUE>` | ``NONE`` and ``NOT_NONE`` variants |
1547+
| | | :opcode:`POP_JUMP_FORWARD_IF_* | for each direction |
1548+
| | <POP_JUMP_FORWARD_IF_TRUE>` | |
1549+
+------------------------------------+-----------------------------------+-----------------------------------------+
1550+
| | :opcode:`!SETUP_WITH` | :opcode:`BEFORE_WITH` | :keyword:`with` block setup |
1551+
| | :opcode:`!SETUP_ASYNC_WITH` | | |
1552+
+------------------------------------+-----------------------------------+-----------------------------------------+
1553+
1554+
.. [#bytecode-jump] All jump opcodes are now relative, including the
1555+
existing :opcode:`JUMP_IF_TRUE_OR_POP` and :opcode:`JUMP_IF_FALSE_OR_POP`.
1556+
The argument is now an offset from the current instruction
1557+
rather than an absolute location.
1558+
1559+
1560+
.. _whatsnew311-changed-opcodes:
1561+
.. _whatsnew311-removed-opcodes:
1562+
.. _whatsnew311-changed-removed-opcodes:
1563+
1564+
Changed/removed opcodes
1565+
-----------------------
1566+
1567+
* Changed :opcode:`MATCH_CLASS` and :opcode:`MATCH_KEYS`
1568+
to no longer push an additional boolean value to indicate success/failure.
1569+
Instead, ``None`` is pushed on failure
1570+
in place of the tuple of extracted values.
1571+
1572+
* Changed opcodes that work with exceptions to reflect them
1573+
now being represented as one item on the stack instead of three
1574+
(see :gh:`89874`).
1575+
1576+
* Removed :opcode:`!COPY_DICT_WITHOUT_KEYS`, :opcode:`!GEN_START`,
1577+
:opcode:`!POP_BLOCK`, :opcode:`!SETUP_FINALLY` and :opcode:`!YIELD_FROM`.
15361578

15371579

15381580
.. _whatsnew311-deprecated:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.