[Numpy-discussion] cumsum much slower than simple loop?
Dave Cook
daverz@gmail....
Thu Feb 9 23:41:19 CST 2012
On Thu, Feb 9, 2012 at 9:21 PM, <josef.pktd@gmail.com> wrote:
> strange (if I didn't make a mistake)
>
> In [12]: timeit a.cumsum(0)
> 100 loops, best of 3: 7.17 ms per loop
>
> In [13]: timeit a.T.cumsum(-1).T
> 1000 loops, best of 3: 1.78 ms per loop
>
> In [14]: (a.T.cumsum(-1).T == a.cumsum(0)).all()
> Out[14]: True
>
>
Interesting. I should have mentioned that I'm using numpy 1.5.1 on 64-bit
Ubuntu 10.10. This transpose/compute/transpose trick did not work for me.
In [27]: timeit a.T.cumsum(-1).T
10 loops, best of 3: 18.3 ms per loop
Dave Cook
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120209/e80b27b7/attachment-0001.html
More information about the NumPy-Discussion
mailing list