[Numpy-discussion] speed of numpy.ndarray compared toNumeric.array
EMMEL Thomas
Thomas.EMMEL at 3ds.com
Mon Jan 10 04:04:48 EST 2011
> On Mon, Jan 10, 2011 at 5:09 PM, EMMEL Thomas <Thomas.EMMEL at 3ds.com>
> wrote:
> > To John:
> >
> >> Did you try larger arrays/tuples? I would guess that makes a
> significant
> >> difference.
> >
> > No I didn't, due to the fact that these values are coordinates in 3D
> (x,y,z).
> > In fact I work with a list/array/tuple of arrays with 100000 to 1M of
> elements or more.
> > What I need to do is to calculate the distance of each of these
> elements (coordinates)
> > to a given coordinate and filter for the nearest.
>
> Note that for this exact problem, there are much better methods than
> brute force (O(N^2) for N vectors), through e.g. kd-trees, which work
> very well in low-dimension. This will matter much more than numeric vs
> numpy
>
> cheers,
>
> David
David,
Yes, of course and my real implementation uses exactly these methods,
but there are still issues with the arrays.
Example:
If I would use brute-force it will take ~5000s for a particular example to
find all points in a list of points. Theoretically it should be possible to
come to O(N*log(N)) with would mean ~2s in my case.
My method need ~28s with tuples, but it takes ~30s with Numeric arrays
and ~60s and more with numpy.ndarrays!
I just use the brute-force method since it delivers the most reusable results
for performance testing, the other methods are a bit dependent on the
distribution of points in space.
Thomas
This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged. If you are not one of the named recipients or have received this email in error, (i) you should not read, disclose, or copy it, (ii) please notify sender of your receipt by reply email and delete this email and all attachments, (iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.For other languages, go to http://www.3ds.com/terms/email-disclaimer.
More information about the NumPy-Discussion
mailing list