mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-47009: Streamline list.append for the common case (GH-31864)
This commit is contained in:
parent
f877b40e3f
commit
a0ea7a116c
4 changed files with 41 additions and 27 deletions
|
@ -2213,10 +2213,7 @@ handle_eval_breaker:
|
|||
TARGET(LIST_APPEND) {
|
||||
PyObject *v = POP();
|
||||
PyObject *list = PEEK(oparg);
|
||||
int err;
|
||||
err = PyList_Append(list, v);
|
||||
Py_DECREF(v);
|
||||
if (err != 0)
|
||||
if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0)
|
||||
goto error;
|
||||
PREDICT(JUMP_BACKWARD_QUICK);
|
||||
DISPATCH();
|
||||
|
@ -5044,14 +5041,12 @@ handle_eval_breaker:
|
|||
DEOPT_IF(!PyList_Check(list), PRECALL);
|
||||
STAT_INC(PRECALL, hit);
|
||||
SKIP_CALL();
|
||||
PyObject *arg = TOP();
|
||||
int err = PyList_Append(list, arg);
|
||||
if (err) {
|
||||
PyObject *arg = POP();
|
||||
if (_PyList_AppendTakeRef((PyListObject *)list, arg) < 0) {
|
||||
goto error;
|
||||
}
|
||||
Py_DECREF(arg);
|
||||
Py_DECREF(list);
|
||||
STACK_SHRINK(2);
|
||||
STACK_SHRINK(1);
|
||||
Py_INCREF(Py_None);
|
||||
SET_TOP(Py_None);
|
||||
Py_DECREF(callable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue