On Tue, Aug 19, 2014 at 5:05 PM, Dan Stromberg <drsali...@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.
The latter is what the heapq.nsmallest and heap.nlargest functions do. nsmallest uses a max heap, so the value being evicted is still found at index 0. Curious then if it's performing worse memory-wise than sorted. -- https://mail.python.org/mailman/listinfo/python-list