Author rhettinger
Recipients jab, rhettinger
Date 2009-07-31.19:39:36
SpamBayes Score 9.91321e-09
Marked as misclassified No
Message-id <>
> Except that it's no longer true that "when n==1, it is
> more efficient to use the builtin min() and max() functions."

There's still the dispatch overhead.
If someone needs a n==1 case, they
*should* use min/max for both speed
and clarity.

Also, it is important the the docs
communicate the relationship between
min/max, nlargest/nsmallest, and sorted.

> It's right in the file you linked to. Search for "n * 10" in ...

That is in the pure python version of nsmallest() and that
code is not used (it is overriden by the C version).  The
actual C implementation works differently -- it uses an
underlying maxheap so it can use a cleaner algorithm that
doesn't need switchover tricks.

If you feel like "kicking the ball around", please continue the
discussion on comp.lang.python -- I think we're done here.
Date User Action Args
2009-07-31 19:39:38rhettingersetrecipients: + rhettinger, jab
2009-07-31 19:39:38rhettingersetmessageid: <>
2009-07-31 19:39:37rhettingerlinkissue6614 messages
2009-07-31 19:39:37rhettingercreate