diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-10-26 14:19:42 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-10-26 14:19:42 (GMT) |
commit | 9acadc54e032e13421c8f3ca50e58e7169352891 (patch) | |
tree | 1b04c0527b58e90632f2bfc9936b1f21978e0c00 /Python | |
parent | 2d7062e1b464b0c6e1c66893d86682bebec997e0 (diff) | |
download | cpython-9acadc54e032e13421c8f3ca50e58e7169352891.zip cpython-9acadc54e032e13421c8f3ca50e58e7169352891.tar.gz cpython-9acadc54e032e13421c8f3ca50e58e7169352891.tar.bz2 |
Merged revisions 75714 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75714 | mark.dickinson | 2009-10-26 14:18:44 +0000 (Mon, 26 Oct 2009) | 1 line
Warn against replacing PyNumber_Add with PyNumber_InPlaceAdd in sum
........
Diffstat (limited to 'Python')
-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 ab6049c..297c795 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); |