Message227246
> 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:04 | roippi | set | recipients:
+ roippi, tim.peters, rhettinger, vstinner, stutzbach, xdegaye, vajrasky |
2014-09-22 02:07:04 | roippi | set | messageid: <1411351624.22.0.838062027079.issue19119@psf.upfronthosting.co.za> |
2014-09-22 02:07:04 | roippi | link | issue19119 messages |
2014-09-22 02:07:03 | roippi | create | |
|