Skip to content

Commit cd017e0

Browse files
AA-Turnerhugovk
authored andcommitted
pythonGH-123299: Copyedit 3.14 What's New: CPython bytecode changes (pythonGH-139402)
(cherry picked from commit 8bfdda2) Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 146a37b commit cd017e0

File tree

4 files changed

+77
-17
lines changed

4 files changed

+77
-17
lines changed

Doc/library/dis.rst

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,6 @@ iterations of the loop.
11021102
Pushes ``co_consts[consti]`` onto the stack.
11031103

11041104

1105-
.. opcode:: LOAD_CONST_IMMORTAL (consti)
1106-
1107-
Works as :opcode:`LOAD_CONST`, but is more efficient for immortal objects.
1108-
1109-
11101105
.. opcode:: LOAD_SMALL_INT (i)
11111106

11121107
Pushes the integer ``i`` onto the stack.
@@ -1647,7 +1642,7 @@ iterations of the loop.
16471642

16481643
Pushes a ``NULL`` to the stack.
16491644
Used in the call sequence to match the ``NULL`` pushed by
1650-
:opcode:`LOAD_METHOD` for non-method calls.
1645+
:opcode:`!LOAD_METHOD` for non-method calls.
16511646

16521647
.. versionadded:: 3.11
16531648

@@ -1968,14 +1963,15 @@ but are replaced by real opcodes or removed before bytecode is generated.
19681963
Marks the end of the code block associated with the last ``SETUP_FINALLY``,
19691964
``SETUP_CLEANUP`` or ``SETUP_WITH``.
19701965

1966+
19711967
.. opcode:: JUMP
1972-
.. opcode:: JUMP_NO_INTERRUPT
1968+
JUMP_NO_INTERRUPT
19731969

19741970
Undirected relative jump instructions which are replaced by their
19751971
directed (forward/backward) counterparts by the assembler.
19761972

19771973
.. opcode:: JUMP_IF_TRUE
1978-
.. opcode:: JUMP_IF_FALSE
1974+
JUMP_IF_FALSE
19791975

19801976
Conditional jumps which do not impact the stack. Replaced by the sequence
19811977
``COPY 1``, ``TO_BOOL``, ``POP_JUMP_IF_TRUE/FALSE``.
@@ -1991,12 +1987,6 @@ but are replaced by real opcodes or removed before bytecode is generated.
19911987
This opcode is now a pseudo-instruction.
19921988

19931989

1994-
.. opcode:: LOAD_METHOD
1995-
1996-
Optimized unbound method lookup. Emitted as a ``LOAD_ATTR`` opcode
1997-
with a flag set in the arg.
1998-
1999-
20001990
.. _opcode_collections:
20011991

20021992
Opcode collections

Doc/whatsnew/3.14.rst

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,9 +2800,79 @@ Deprecated
28002800
CPython bytecode changes
28012801
========================
28022802

2803-
* Replaced the opcode ``BINARY_SUBSCR`` by :opcode:`BINARY_OP` with oparg ``NB_SUBSCR``.
2803+
* Replaced the opcode :opcode:`!BINARY_SUBSCR` by the :opcode:`BINARY_OP`
2804+
opcode with the ``NB_SUBSCR`` oparg.
28042805
(Contributed by Irit Katriel in :gh:`100239`.)
28052806

2807+
* Add the :opcode:`BUILD_INTERPOLATION` and :opcode:`BUILD_TEMPLATE`
2808+
opcodes to construct new :class:`~string.templatelib.Interpolation`
2809+
and :class:`~string.templatelib.Template` instances, respectively.
2810+
(Contributed by Lysandros Nikolaou and others in :gh:`132661`;
2811+
see also :ref:`PEP 750: Template strings <whatsnew314-pep750>`).
2812+
2813+
* Remove the :opcode:`!BUILD_CONST_KEY_MAP` opcode.
2814+
Use :opcode:`BUILD_MAP` instead.
2815+
(Contributed by Mark Shannon in :gh:`122160`.)
2816+
2817+
* Replace the :opcode:`!LOAD_ASSERTION_ERROR` opcode with
2818+
:opcode:`LOAD_COMMON_CONSTANT` and add support for loading
2819+
:exc:`NotImplementedError`.
2820+
2821+
* Add the :opcode:`LOAD_FAST_BORROW` and :opcode:`LOAD_FAST_BORROW_LOAD_FAST_BORROW`
2822+
opcodes to reduce reference counting overhead when the interpreter can prove
2823+
that the reference in the frame outlives the reference loaded onto the stack.
2824+
(Contributed by Matt Page in :gh:`130704`.)
2825+
2826+
* Add the :opcode:`LOAD_SMALL_INT` opcode, which pushes a small integer
2827+
equal to the ``oparg`` to the stack.
2828+
The :opcode:`!RETURN_CONST` opcode is removed as it is no longer used.
2829+
(Contributed by Mark Shannon in :gh:`125837`.)
2830+
2831+
* Add the new :opcode:`LOAD_SPECIAL` instruction.
2832+
Generate code for :keyword:`with` and :keyword:`async with` statements
2833+
using the new instruction.
2834+
Removed the :opcode:`!BEFORE_WITH` and :opcode:`!BEFORE_ASYNC_WITH` instructions.
2835+
(Contributed by Mark Shannon in :gh:`120507`.)
2836+
2837+
* Add the :opcode:`POP_ITER` opcode to support 'virtual' iterators.
2838+
(Contributed by Mark Shannon in :gh:`132554`.)
2839+
2840+
Pseudo-instructions
2841+
-------------------
2842+
2843+
* Add the :opcode:`!ANNOTATIONS_PLACEHOLDER` pseudo instruction
2844+
to support partially executed module-level annotations with
2845+
:ref:`deferred evaluation of annotations <whatsnew314-pep649>`.
2846+
(Contributed by Jelle Zijlstra in :gh:`130907`.)
2847+
2848+
* Add the :opcode:`!BINARY_OP_EXTEND` pseudo instruction,
2849+
which executes a pair of functions (guard and specialization functions)
2850+
accessed from the inline cache.
2851+
(Contributed by Irit Katriel in :gh:`100239`.)
2852+
2853+
* Add three specializations for :opcode:`CALL_KW`;
2854+
:opcode:`!CALL_KW_PY` for calls to Python functions,
2855+
:opcode:`!CALL_KW_BOUND_METHOD` for calls to bound methods, and
2856+
:opcode:`!CALL_KW_NON_PY` for all other calls.
2857+
(Contributed by Mark Shannon in :gh:`118093`.)
2858+
2859+
* Add the :opcode:`JUMP_IF_TRUE` and :opcode:`JUMP_IF_FALSE` pseudo instructions,
2860+
conditional jumps which do not impact the stack.
2861+
Replaced by the sequence ``COPY 1``, ``TO_BOOL``, ``POP_JUMP_IF_TRUE/FALSE``.
2862+
(Contributed by Irit Katriel in :gh:`124285`.)
2863+
2864+
* Add the :opcode:`!LOAD_CONST_MORTAL` pseudo instruction.
2865+
(Contributed by Mark Shannon in :gh:`128685`.)
2866+
2867+
* Add the :opcode:`!LOAD_CONST_IMMORTAL` pseudo instruction,
2868+
which does the same as :opcode:`!LOAD_CONST`, but is more efficient
2869+
for immortal objects.
2870+
(Contributed by Mark Shannon in :gh:`125837`.)
2871+
2872+
* Add the :opcode:`NOT_TAKEN` pseudo instruction, used by :mod:`sys.monitoring`
2873+
to record branch events (such as :monitoring-event:`BRANCH_LEFT`).
2874+
(Contributed by Mark Shannon in :gh:`122548`.)
2875+
28062876

28072877
C API changes
28082878
=============

Doc/whatsnew/3.7.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2483,7 +2483,7 @@ avoiding possible problems use new functions :c:func:`PySlice_Unpack` and
24832483
CPython bytecode changes
24842484
------------------------
24852485

2486-
There are two new opcodes: :opcode:`LOAD_METHOD` and :opcode:`!CALL_METHOD`.
2486+
There are two new opcodes: :opcode:`!LOAD_METHOD` and :opcode:`!CALL_METHOD`.
24872487
(Contributed by Yury Selivanov and INADA Naoki in :issue:`26110`.)
24882488

24892489
The :opcode:`!STORE_ANNOTATION` opcode has been removed.

Misc/NEWS.d/3.14.0a2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ The :class:`memoryview` type now supports subscription, making it a
14001400
.. nonce: KlCdgD
14011401
.. section: Core and Builtins
14021402
1403-
Adds :opcode:`LOAD_SMALL_INT` and :opcode:`LOAD_CONST_IMMORTAL`
1403+
Adds :opcode:`LOAD_SMALL_INT` and :opcode:`!LOAD_CONST_IMMORTAL`
14041404
instructions. ``LOAD_SMALL_INT`` pushes a small integer equal to the
14051405
``oparg`` to the stack. ``LOAD_CONST_IMMORTAL`` does the same as
14061406
``LOAD_CONST`` but is more efficient for immortal objects. Removes

0 commit comments

Comments
 (0)