[Numpy-discussion] efficient use of numpy.where() and .any()
Pierre GM
pgmdevlist@gmail....
Mon Apr 23 11:36:23 CDT 2007
> When you say "no python temps" I guess you mean, no temporary
> *variables*? If I understand correctly, this allocates a temporary
> boolean array to hold the result of "a<0".
Indeed, hence my precising "no *python* temps". There still be a tmp created
at one point or another (if I'm not mistaken)
> This is an unfortunate limitation that comes from the fact that we
> can't override the behaviour of python's logical operations. a<b<c
> does the right thing for python scalars, but it does it by being
> expanded to (approximately) "a<b and b<c", and "and" doesn't do the
> right thing for arrays.
Note that in addition of the bitwise operators, you can use the "logical_"
functions. OK, you'll still end up w/ temporaries, but I wonder whether there
couldn't be some tricks to bypass that...
More information about the Numpy-discussion
mailing list