diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2022-04-01 10:23:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 10:23:42 (GMT) |
commit | a0ea7a116ce52a178c02d42b684089758bd7f355 (patch) | |
tree | 052ce2e531b12a0f3d2f8242a8a346c0ad9dadba /Python | |
parent | f877b40e3f7e0d97878884d80fbec879a85ab7e8 (diff) | |
download | cpython-a0ea7a116ce52a178c02d42b684089758bd7f355.zip cpython-a0ea7a116ce52a178c02d42b684089758bd7f355.tar.gz cpython-a0ea7a116ce52a178c02d42b684089758bd7f355.tar.bz2 |
bpo-47009: Streamline list.append for the common case (GH-31864)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 8f73ea1..8c1f21b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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); |