[issue32895] Make general function sum() use Numpy's sum when obviously possible

Uri Elias report at bugs.python.org
Wed Feb 21 09:06:26 EST 2018


New submission from Uri Elias <uri.urie at gmail.com>:

True at least to PY2.7 and 3.5 - given x is a numpy array, say np.random.rand(int(1e6)), then sum(x) is much slower (for 1e6 elements - 2 orders of magnitude) than x.sum(). 
Now, while this is understandable behaviour, I wander how hard it is to add a condition that if argument is a Numpy object then use its own sum. 
I think many programmers aren't aware of that, so all in all it can improve the performance of a lot of existing code.

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 312495
nosy: urielias
priority: normal
severity: normal
status: open
title: Make general function sum() use Numpy's sum when obviously possible
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32895>
_______________________________________


More information about the Python-bugs-list mailing list