From ffaea8d3f9f56984ddbd061fdffd8e1fcbde1e9f Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 9 Oct 2019 23:13:57 -0700 Subject: [PATCH 1/2] Optimize list sums. --- Python/ceval.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Python/ceval.c b/Python/ceval.c index a7d2ea80069a06..453c5367279774 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1551,6 +1551,11 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) sum = unicode_concatenate(tstate, left, right, f, next_instr); /* unicode_concatenate consumed the ref to left */ } + else if (PyList_CheckExact(left) && PyList_CheckExact(right) + && Py_REFCNT(left) == 1) { + sum = PySequence_InPlaceConcat(left, right); + Py_DECREF(left); + } else { sum = PyNumber_Add(left, right); Py_DECREF(left); From 660939c086a44c0b41df5bed5539eb5466fddf3b Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2019 19:20:27 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2019-10-10-19-20-24.bpo-38436.LfVbc-.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-10-10-19-20-24.bpo-38436.LfVbc-.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-10-10-19-20-24.bpo-38436.LfVbc-.rst b/Misc/NEWS.d/next/Core and Builtins/2019-10-10-19-20-24.bpo-38436.LfVbc-.rst new file mode 100644 index 00000000000000..de7aa3fa4443ae --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-10-10-19-20-24.bpo-38436.LfVbc-.rst @@ -0,0 +1 @@ +Improved the performance of repeated/literal :class:`list` addition. \ No newline at end of file