Skip to content

Commit 5e433d6

Browse files
committed
LIST_APPEND (a bit unhappy with it)
1 parent 8d0b47c commit 5e433d6

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Python/bytecodes.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,10 @@ dummy_func(
468468
DISPATCH_INLINED(new_frame);
469469
}
470470

471-
// stack effect: (__0 -- )
472-
inst(LIST_APPEND) {
473-
PyObject *v = POP();
474-
PyObject *list = PEEK(oparg);
475-
if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0)
476-
goto error;
471+
// Alternative: (list, unused[oparg], v -- list, unused[oparg])
472+
inst(LIST_APPEND, (v --)) {
473+
PyObject *list = PEEK(oparg + 1); // +1 to account for v staying on stack
474+
ERROR_IF(_PyList_AppendTakeRef((PyListObject *)list, v) < 0, error);
477475
PREDICT(JUMP_BACKWARD);
478476
}
479477

Python/generated_cases.c.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)