[Numpy-discussion] setmember1d memory leak?
cimrman3 at ntc.zcu.cz
Thu Jan 25 06:35:10 EST 2007
Robert Cimrman wrote:
> Charles R Harris wrote:
>> In : def countmembers(a1, a2) :
>> ...: a = sort(a2)
>> ...: il = a.searchsorted(a1, side='l')
>> ...: ir = a.searchsorted(a1, side='r')
>> ...: return ir - il
>> The subtraction can be replaced by != to get a boolean mask.
> It looks good! Isn't it faster than setmember1d for unique input arrays?
> I do not like setmember1d much (it is long unlike other functions in
> arraysetops and looks clumsy to me now and I do not understand it
> anymore...), so feel free to replace it.
> BTW. setmember1d gives me the same mask as countmembers for several
> non-unique inputs I tried...
But still a function like 'findsorted' returning a bool mask would be
handy - one searchsorted-like call could be saved in setmember1d.
More information about the NumPy-Discussion