On Apr 23, 1:24 am, Bryan <bryanjugglercryptograp...@yahoo.com> wrote: > That is interesting. The above algorithm for nlargest is better, but > to use it for nsmallest requires a largest-on-top heap, which the > module does not bother to implement.
FWIW, the pure python versions differ because they are both implemented in terms of the basic minheap functions, but the underlying C code uses the same algorithm for both (using an underlying maxheap when necessary): http://svn.python.org/view/python/branches/py3k/Modules/_heapqmodule.c?revision=64351&view=markup Raymond -- http://mail.python.org/mailman/listinfo/python-list