[Numpy-discussion] efficient use of numpy.where() and .any()

Anne Archibald peridot.faceted@gmail....
Mon Apr 23 11:47:07 CDT 2007

On 23/04/07, Pierre GM <pgmdevlist@gmail.com> wrote:

> 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...

If you're really determined not to make many temps, you can use their
output arguments and do it all in-place on the first temporary. The
few times I've rewritten code that way it hasn't made an appreciable
positive difference in the speed, and it was sometimes significantly
slower, perhaps because of the increased memory footprint (the temps
were longer-lived than when I did it by hand). malloc() is really
really cheap, and garbage collection is also extremely cheap for huge


More information about the Numpy-discussion mailing list