<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 16, 2014 at 4:18 PM,  <span dir="ltr"><<a href="mailto:josef.pktd@gmail.com" target="_blank">josef.pktd@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Sun, Feb 16, 2014 at 6:15 PM,  <<a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a>> wrote:<br>

> On Sun, Feb 16, 2014 at 5:50 PM, Eelco Hoogendoorn<br>
> <<a href="mailto:hoogendoorn.eelco@gmail.com">hoogendoorn.eelco@gmail.com</a>> wrote:<br>
>><br>
>> My guess;<br>
>><br>
>> First of all, you are actually manipulating twice as much data as opposed to<br>
>> an inplace sort.<br>
>><br>
>> Moreover, an inplace sort gains locality as it is being sorted, whereas the<br>
>> argsort is continuously making completely random memory accesses.<br>
>><br>
>><br>
>> -----Original Message-----<br>
>> From: <a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a><br>
>> Sent: Sunday, February 16, 2014 11:43 PM<br>
>> To: Discussion of Numerical Python<br>
>> Subject: [Numpy-discussion] argsort speed<br>
>><br>
>> currently using numpy 1.6.1<br>
>><br>
>> What's the fastest argsort for a 1d array with around 28 Million<br>
>> elements, roughly uniformly distributed, random order?<br>
>><br>
>> Is there a reason that np.argsort is almost 3 times slower than np.sort?<br>
>><br>
>> I'm doing semi-systematic timing for a stats(models) algorithm.<br>
><br>
> I was using np.sort, inplace sort is only a little bit faster<br>
><br>
> It looks like sorting first, and then argsorting is faster than argsort alon<br>
><br>
> pvals.sort()<br>
> sortind = np.argsort(pvals)<br>
<br>
</div>Ok, that was useless, that won't be anything I want.<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>I think locality is the most important thing. The argsort routines used to move both the indexes and the array to argsort, the new ones only move the indexes. It is a tradeoff, twice as many moves vs locality. It's probably possible to invent an algorithm that mixes the two.<br>
<br></div><div><snip><br><br></div><div>Chuck<br></div></div></div></div>