Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76609
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: efficient partial sort in Python ? |
| Date | 2014-08-19 18:11 -0400 |
| References | <51dfbe9b-f6e0-4532-bc2d-e7ce2fc282b5@googlegroups.com> <mailman.13116.1408398154.18130.python-list@python.org> <3fb3b4d1-a7e2-4912-a878-7d5e1798aee6@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13168.1408486351.18130.python-list@python.org> (permalink) |
On 8/19/2014 3:37 PM, Chiu Hsiang Hsu wrote: > On Tuesday, August 19, 2014 5:42:27 AM UTC+8, Dan Stromberg wrote: >> On Mon, Aug 18, 2014 at 10:18 AM, Chiu Hsiang Hsu >> <wdv4758h@gmail.com> wrote: >> >>> I know that Python use Timsort as default sorting algorithm and >>> it is efficient, Especially with data that is partially ordered already. >>> but I just wanna have a partial sorting (n-largest/smallest >>> elements). >> Perhaps heapq with Pypy? Or with nuitka? Or with numba? > I heard of PyPy and numba before, but I doesn't know nuitka, thanks > for your information. > > Another problem with heapq is the memory usage, it cost a lot of more > memory with heapq in CPython (I test it in 3.4 with 1000000 float > numbers) compare to sorted. > > For curiosity, there are many speed up solution in Python (like > Cython, PyPy), I hasn't use Cython before, I guess PyPy is a more > convient way to speed up current Python code (?), so how does Cython > compare to PyPy ? (speed, code, flexibility, or anything else) Why are you rejecting the previous answer: use .sort and pick out whatever items you want? -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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