[Numpy-discussion] Re: ***[Possible UCE]*** [SciPy-user] Regarding what "where" returns

Travis Oliphant oliphant.travis at ieee.org
Thu Apr 13 08:43:14 CDT 2006


Robert Cimrman wrote:
> Travis Oliphant wrote:
>> I went ahead and made this change to the code.    The nonzero 
>> function still behaves as before (and in fact only works for 1-d 
>> arrays as it did in Numeric).
>>
>> The where(condition)  function works the same as condition.nonzero() 
>> and both always return a tuple.
>
> So, for 1-d arrays, using 'nonzero( condition )' should be faster than 
> 'where( condition )[0]', right?
>
No.  since the function just selects off the first element of the tuple 
returned by the method...

'condition.nonzero()[0]'  may be *slightly* faster than 
'where(condition)[0]'  however

-Travis





More information about the Numpy-discussion mailing list