A Monday 11 February 2008, Charles R Harris escrigué:> On Feb 8, 2008 5:29 AM, Francesc Altet <faltet@carabos.com> wrote:That's good to know. However, I'm curious about where it is the
> > Hi,
> >
> > I'm a bit confused that the sort method of a string character
> > doesn't
> >
> > allow a mergesort:
> > >>> s = numpy.empty(10, "S10")
> > >>> s.sort(kind="merge")
> >
> > TypeError: desired sort not supported for this type
> >
> > However, by looking at the numpy sources, it seems that the only
> > implemented method for sorting array strings is "merge" (I presume
> > because it is stable). So, perhaps the message above should be
> > fixed.
>
> The only available method is the default quicksort. The mergesort is
> for argsort and was put in for lexsort to use.
specific quicksort implementation for strings/unicode. I've had a look
at _sortmodule.c.src, but I can only find a quicksort implementation
for:
The version you are testing is your own or the one that I provided?
Here are the timings for my laptop:
In [55]: a = np.random.rand(10000).astype('S8')
In [56]: %timeit a.copy().sort()
100 loops, best of 3: 3.82 ms per loop
In [57]: %timeit newqsort(a.copy())
100 loops, best of 3: 3.29 ms per loop
Here, the difference in performance has been reduced to a mere 15%
(still favouring newqsort). So, with this, it seems like the
performance of the original sorting in NumPy only suffers a lot when
running in old processors (eg. Pentium 4), while the performance is
reasonable with newer ones (Opteron).