[Numpy-discussion] array.min() vs. min(array)

Ryan Krauss ryanlists at gmail.com
Wed Apr 26 14:21:07 CDT 2006


I was spending some time trying to track down how to speed up an
algorithm that gets called a bunch of times during an optimization.  I
was startled when I finally figured out that most of the time was
wasted by using the built-in pyhton min function.  It turns out that
in my case, using array.min() (i.e. the method of the Numpy array) is
300-500 times faster than the built-in python min function (i.e.
min(array)).

So, thank you Travis and everyone who has put so much time into
thinking through Numpy and making it fast (as well as making sure it
is correct).

And to the rest of us, use the Numpy array methods whenever you can.

Thanks,

Ryan




More information about the Numpy-discussion mailing list