diff options
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ab6049cabf..297c795ca3 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1958,6 +1958,15 @@ builtin_sum(PyObject *self, PyObject *args) } break; } + /* It's tempting to use PyNumber_InPlaceAdd instead of + PyNumber_Add here, to avoid quadratic running time + when doing 'sum(list_of_lists, [])'. However, this + would produce a change in behaviour: a snippet like + + empty = [] + sum([[x] for x in range(10)], empty) + + would change the value of empty. */ temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item); |