Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-11 Thread Elliot Gorokhovsky
But the sort mutates F...does the setup get executed each time? I thought it's just at the beginning. So then F gets mutated (sorted) and subsequent sorts time wrong. On Tue, Oct 11, 2016, 7:51 AM Paul Moore <p.f.mo...@gmail.com> wrote: > On 11 October 2016 at 14:04, Elliot Go

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-11 Thread Elliot Gorokhovsky
sort time, right, so wouldn't that mess up the benchmark? Or does timeit separate the times? On Tue, Oct 11, 2016, 2:22 AM Paul Moore <p.f.mo...@gmail.com> wrote: > On 11 October 2016 at 03:15, Elliot Gorokhovsky > <elliot.gorokhov...@gmail.com> wrote: > > There's an optio

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-10 Thread Elliot Gorokhovsky
needlessly offensive > language in his first post. > > On Mon, Oct 10, 2016 at 5:09 PM, Steven D'Aprano <st...@pearwood.info> > wrote: > > On Mon, Oct 10, 2016 at 09:16:32PM +, Elliot Gorokhovsky wrote: > > > >> Anyway, benchmarking technique aside,

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-10 Thread Elliot Gorokhovsky
/sort():", 1-fastlist_time/defaultlist_time) print("Integer benchmarks") bench_list(1, 1e7) bench_list(5, 1e7/5) bench_list(10, 1e7/10) bench_list(1000, 1e7/1000) bench_list(100, 1e7/1e6) Is that a valid way to benchmark the implementation? On Mon, Oct 10, 2016 at 8:15 P

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-10 Thread Elliot Gorokhovsky
nearly the same code? Anyway, benchmarking technique aside, the point is that it it works well for small lists (i.e. doesn't affect performance). On Mon, Oct 10, 2016 at 2:53 PM Nathaniel Smith <n...@pobox.com> wrote: > On Mon, Oct 10, 2016 at 1:42 PM, Elliot Gorokhovsky > <

Re: [Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-10 Thread Elliot Gorokhovsky
odule that subclasses list, so I can't just drop it into existing code without modification. Let me know if you have any other questions/suggestions! On Mon, Oct 10, 2016 at 12:18 AM Elliot Gorokhovsky < elliot.gorokhov...@gmail.com> wrote: > Hi, > > I posted here a while back as

[Python-Dev] Optimizing list.sort() by checking type in advance

2016-10-10 Thread Elliot Gorokhovsky
Hi, I posted here a while back asking what you guys thought about implementing radix sort for strings in list.sort(). You gave me a lot of reasons why that would be a bad idea. However, it got me thinking, and I came up with something that you may find interesting. First, some simple benchmark

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-11 Thread Elliot Gorokhovsky
retty busy...but I'll try to get on this as soon as I can). On Sun, Sep 11, 2016 at 3:42 PM Tim Peters <tim.pet...@gmail.com> wrote: > [redirected from python-dev, to python-ideas; > please send followups only to python-ideas] > > [Elliot Gorokhovsky <elgo8...@colorado.edu>]

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-11 Thread Elliot Gorokhovsky
The sort can be made stable, but that requires the allocation of an equal-sized auxiliary array. To quote from the paper: "Both list-based and two-array sorts entail Θ(n) space overhead. That overhead shrinks to Θ(logn) in American flag sort, which, like quicksort, trades off stability for space

Re: [Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-11 Thread Elliot Gorokhovsky
Thanks for the link. If you look at the conclusion it says "We recommend American flag sort as an all-round algorithm for sorting strings." On Sun, Sep 11, 2016, 11:30 AM Raymond Hettinger < raymond.hettin...@gmail.com> wrote: > > > On Sep 11, 2016, at 12:45 AM,

[Python-Dev] Drastically improving list.sort() for lists of strings/ints

2016-09-11 Thread Elliot Gorokhovsky
Hello all, I am interested in making a non-trivial improvement to list.sort(), but before I put in the work, I want to test the waters and see if this is something the community would accept. Basically, I want to implement radix sort for lists of strings. So list.sort() would detect if it is