On Fri, Sep 5, 2008 at 9:08 AM, David Cournapeau <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 5, 2008 at 11:52 PM, Keith Goodman <[EMAIL PROTECTED]> wrote:
>
>> Here's another difference:
>>
>>>> a = np.random.randn(100000)
>>>> timeit np.sum(a[np.where(a>0)])
>> 100 loops, best of 3: 3.44 ms per loop
>>>> timeit a[a > 0].sum()
>> 100 loops, best of 3: 2.21 ms per loop
>
> But you're not comparing the same thing: why calling where in one case
> and not in the other ? The difference is in the where call, not in the
> a.sum() vs sum(a)

I was comparing the two techniques from this question:

Ludwig wrote:
> What are the relative merits of
>
> sum(a[where(a>0])
>
> to
>
> a[a > 0].sum()
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to