This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nilton
Recipients nilton
Date 2008-12-31.01:07:16
SpamBayes Score 5.0426193e-06
Marked as misclassified No
Message-id <1230685640.21.0.309220494864.issue4790@psf.upfronthosting.co.za>
In-reply-to
Content
The wrapper around heapq.nlargest and heapq.nsmallest is much slower
than it's C version.

$ python2.5 -mtimeit -s 'import random; random.seed(123); n=999999;
x=range(n); random.shuffle(x); import _heapq' '_heapq.nlargest(3, x)'
10 loops, best of 3: 142 msec per loop

$ python2.5 -mtimeit -s 'import random; random.seed(123); n=999999;
x=range(n); random.shuffle(x); import heapq' 'heapq.nlargest(3, x)'
10 loops, best of 3: 685 msec per loop


If the key argument is None, there is no need to use the wrapper. This
patch adds an a check to avoid this.
History
Date User Action Args
2008-12-31 01:07:20niltonsetrecipients: + nilton
2008-12-31 01:07:20niltonsetmessageid: <1230685640.21.0.309220494864.issue4790@psf.upfronthosting.co.za>
2008-12-31 01:07:18niltonlinkissue4790 messages
2008-12-31 01:07:17niltoncreate