Skip to content

Commit 57e891e

Browse files
committed
Address review comments
1 parent 7e4b2a8 commit 57e891e

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

Include/internal/pycore_magic_number.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Known values:
261261
Python 3.14a1 3606 (Specialize CALL_KW)
262262
Python 3.14a1 3607 (Add pseudo instructions JUMP_IF_TRUE/FALSE)
263263
Python 3.14a1 3608 (Add support for slices)
264-
Python 3.14a2 3609 (Add LOAD_INT and LOAD_CONST_IMMORTAL instructions)
264+
Python 3.14a2 3609 (Add LOAD_INT and LOAD_CONST_IMMORTAL instructions, remove RETURN_CONST)
265265
266266
Python 3.15 will start with 3650
267267

Lib/test/test_ast/test_ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ def get_load_const(self, tree):
23032303
co = compile(tree, '<string>', 'exec')
23042304
consts = []
23052305
for instr in dis.get_instructions(co):
2306-
if instr.opname in ('LOAD_CONST', 'LOAD_CONST_IMMORTAL', 'LOAD_INT'):
2306+
if instr.opcode in dis.hasconst:
23072307
consts.append(instr.argval)
23082308
return consts
23092309

Misc/NEWS.d/next/Core_and_Builtins/2024-10-25-15-56-14.gh-issue-125837.KlCdgD.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Adds :opcode:`LOAD_INT` and :opcode:`LOAD_CONST_IMMORTAL` instructions.
22
``LOAD_INT`` pushes a small integer equal to the ``oparg`` to the stack.
33
``LOAD_CONST_IMMORTAL`` does the same as ``LOAD_CONST`` but is more
44
efficient for immortal objects.
5+
Removes ``RETRUN_CONST`` instruction.

Python/codegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ codegen_setup_annotations_scope(compiler *c, location loc,
665665
key, loc.lineno, NULL, &umd));
666666

667667
// Insert None into consts to prevent an annotation
668-
// apperaing to be a docstring
668+
// appearing to be a docstring
669669
_PyCompile_AddConst(c, Py_None);
670670
// if .format != 1: raise NotImplementedError
671671
_Py_DECLARE_STR(format, ".format");

Python/flowgraph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ convert_pseudo_conditional_jumps(cfg_builder *g)
24192419
}
24202420

24212421
static int
2422-
convert_pseudo_ops(cfg_builder *g, int is_generator)
2422+
convert_pseudo_ops(cfg_builder *g)
24232423
{
24242424
basicblock *entryblock = g->g_entryblock;
24252425
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {

Python/specialize.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ _PyCode_Quicken(PyCodeObject *code)
448448
for (int i = 0; i < Py_SIZE(code)-1; i++) {
449449
opcode = instructions[i].op.code;
450450
int caches = _PyOpcode_Caches[opcode];
451+
oparg = (oparg << 8) | instructions[i].op.arg;
451452
if (caches) {
452453
// The initial value depends on the opcode
453454
switch (opcode) {
@@ -469,16 +470,13 @@ _PyCode_Quicken(PyCodeObject *code)
469470
else if (opcode == LOAD_CONST) {
470471
/* We can't do this in the bytecode compiler as
471472
* marshalling can intern strings and make them immortal. */
472-
oparg = (oparg << 8) | instructions[i].op.arg;
473+
473474
PyObject *obj = PyTuple_GET_ITEM(code->co_consts, oparg);
474475
if (_Py_IsImmortal(obj)) {
475476
instructions[i].op.code = LOAD_CONST_IMMORTAL;
476477
}
477478
}
478-
if (opcode == EXTENDED_ARG) {
479-
oparg = (oparg << 8) | instructions[i].op.arg;
480-
}
481-
else {
479+
if (opcode != EXTENDED_ARG) {
482480
oparg = 0;
483481
}
484482
}

0 commit comments

Comments
 (0)