[Numpy-discussion] record arrays initialization

Kevin Jacobs <jacobs@bioinformed.com> bioinformed at gmail.com
Wed May 2 19:46:21 EDT 2012

On Wed, May 2, 2012 at 7:25 PM, Aronne Merrelli
<aronne.merrelli at gmail.com>wrote:

> In general this is a good suggestion - I was going to mention it
> earlier - but I think for this particular problem it is not better
> than the "brute force" and argmin() NumPy approach. On my laptop, the
> KDTree query is about a factor of 7 slower (ignoring the time cost to
> create the KDTree)
The cKDTree implementation is more than 4 times faster than the brute-force

T = scipy.spatial.cKDTree(targets)

In [11]: %timeit foo1(element, targets)   # Brute force
1000 loops, best of 3: 385 us per loop

In [12]: %timeit foo2(element, T)         # cKDTree
10000 loops, best of 3: 83.5 us per loop

In [13]: 385/83.5
Out[13]: 4.610778443113772

A FLANN implementation should be even faster--perhaps by as much as another
factor of two.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120502/52ee50de/attachment.html>

More information about the NumPy-Discussion mailing list