Re: [pypy-dev] Sorting structs

2016-10-03 Thread Tuom Larsen
Hello Carl, thanks a lot for the clarification and for creating the ticket! On Mon, Oct 3, 2016 at 7:28 PM, Carl Friedrich Bolz wrote: > Hi Tuom, > > The problem is the key=... argument to sort, which isn't optimized > well. This kind of code is much faster: > > wrapped_data = [(p.x, p) for

Re: [pypy-dev] Sorting structs

2016-10-03 Thread Carl Friedrich Bolz
Hi Tuom, The problem is the key=... argument to sort, which isn't optimized well. This kind of code is much faster: wrapped_data = [(p.x, p) for p in data] wrapped_data.sort() data = [it[1] for it in wrapped_data] We should fix this problem. I've created an issue so it doesn't get lo

Re: [pypy-dev] Sorting structs

2016-10-03 Thread Tuom Larsen
Thanks for the reply! I don't think a reverse counter is better because TimSort (used in PyPy?) is able to recognise the pattern [1] and do better than other kinds of sorts. And almost for a year [2] now, V8 implements random as XorShift128+ which very good. I also tried different sizes and the ti

Re: [pypy-dev] Sorting structs

2016-10-03 Thread Leonardo Santagada
Can you start by having a stable benchmark? Instead of calling random have a reverse counter to create your list in reverse order. That will at least get somewhat similar work on both languages (javascript random is notoriously bad at being random). Maybe the difference in performance is all from