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 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 <1411351624.22.0.838062027079.issue19119@psf.upfronthosting.co.za>
In-reply-to
Content
> 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)
History
Date User Action Args
2014-09-22 02:07:04roippisetrecipients: + roippi, tim.peters, rhettinger, vstinner, stutzbach, xdegaye, vajrasky
2014-09-22 02:07:04roippisetmessageid: <1411351624.22.0.838062027079.issue19119@psf.upfronthosting.co.za>
2014-09-22 02:07:04roippilinkissue19119 messages
2014-09-22 02:07:03roippicreate