Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76622

Re: efficient partial sort in Python ?

References <51dfbe9b-f6e0-4532-bc2d-e7ce2fc282b5@googlegroups.com> <mailman.13116.1408398154.18130.python-list@python.org> <3fb3b4d1-a7e2-4912-a878-7d5e1798aee6@googlegroups.com> <CAGGBd_pkisTMGcJ0S7c+eD3JXdSv3rHCwKD_PWb9dx1YQagkfg@mail.gmail.com> <CAGGBd_rwWvt+kGas0svbuR0oxNFRFyZ7d-8RDSuO9dJSY3bLzQ@mail.gmail.com>
Date 2014-08-19 16:22 -0700
Subject Re: efficient partial sort in Python ?
From Dan Stromberg <drsalists@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13179.1408490569.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Aug 19, 2014 at 4:10 PM, Dan Stromberg <drsalists@gmail.com> wrote:
> On Tue, Aug 19, 2014 at 4:05 PM, Dan Stromberg <drsalists@gmail.com> wrote:
>> When you use heapq, are you putting all the values in the heap, or
>> just up to n at a time (evicting the worst value, one at a time as you
>> go)?  If you're doing the former, it's basically a heapsort which
>> probably won't beat timsort.  If you're doing the latter, that should
>> be pretty good.
>
> It just occurred to me that evicting the highest value each step of
> the way might be expensive with a traditional heap (since the value at
> the largest array index isn't necessarily the largest).  I've
> experimented with doing this using a treap a bit:
> http://stromberg.dnsalias.org/~strombrg/treap/  You might try that.

Or more directly relevant:
http://stromberg.dnsalias.org/~strombrg/highest/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

efficient partial sort in Python ? Chiu Hsiang Hsu <wdv4758h@gmail.com> - 2014-08-18 10:18 -0700
  Re: efficient partial sort in Python ? Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-18 12:48 -0600
  Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-18 14:42 -0700
    Re: efficient partial sort in Python ? Chiu Hsiang Hsu <wdv4758h@gmail.com> - 2014-08-19 12:37 -0700
      Re: efficient partial sort in Python ? Terry Reedy <tjreedy@udel.edu> - 2014-08-19 18:11 -0400
      Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-19 16:05 -0700
      Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-19 16:10 -0700
      Re: efficient partial sort in Python ? Dan Stromberg <drsalists@gmail.com> - 2014-08-19 16:22 -0700
      Re: efficient partial sort in Python ? Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-19 18:00 -0600

csiph-web