On Sat, Apr 12, 2014 at 8:02 AM, Alan G Isaac <alan.is...@gmail.com> wrote:
> 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? > > The Python operators for ndarrays can be dynamically set, but they are initialized by the ufunc module (don't ask) as follows. #define BOOL_invert BOOL_logical_not #define BOOL_negative BOOL_logical_not #define BOOL_add BOOL_logical_or #define BOOL_bitwise_and BOOL_logical_and #define BOOL_bitwise_or BOOL_logical_or #define BOOL_bitwise_xor BOOL_logical_xor #define BOOL_multiply BOOL_logical_and #define BOOL_subtract BOOL_logical_xor So they are all equivalent to logical_* functions. Chuck
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion