[Numpy-discussion] boolean operations on boolean arrays

Alan G Isaac alan.isaac at gmail.com
Sat Apr 12 10:02:05 EDT 2014


This is a very basic question.
Suppose `a` and `b` are boolean arrays with the same shape.
Are there any considerations besides convenience in choosing
between:

a&b           a*b         logical_and(a,b)
a|b           a+b         logical_or(a,b)
~a            True-a      logical_not(a)

I somewhat expect the last column to be slowest
as well as least convenient, since it is built to
first convert non-booleans to booleans.
Are there other differences?
Also, is this made clear anywhere in the docs?

Thanks,
Alan Isaac



More information about the NumPy-Discussion mailing list