Author roippi
Recipients rhettinger, roippi, stutzbach, tim.peters, vajrasky, vstinner, xdegaye
Date 2014-09-22.02:07:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> The major issue (there are other issues as well but not so difficult) is whether nlargest and nsmallest should support iterator that could be endless iterator or reject it (by checking __len__ attribute) straight away.

Well, failing with an exception isn't right.  I can imagine doing (and probably have done, at some point) nlargest on any number of generators, streams of data, etc.

So unless anyone can solve the halting problem (:-)) the behavior of nlargest is correct as possible; nlargest(2, GetOnly()) behaves just like list(GetOnly()) - they both hang forever.

The proper action here is just a fix in the tests: make GetOnly raise IndexError at some point so that it is a proper sequence.  (also rename the second test to get_cmp_only)
Date User Action Args
2014-09-22 02:07:04roippisetrecipients: + roippi, tim.peters, rhettinger, vstinner, stutzbach, xdegaye, vajrasky
2014-09-22 02:07:04roippisetmessageid: <>
2014-09-22 02:07:04roippilinkissue19119 messages
2014-09-22 02:07:03roippicreate