On 2016-11-30 17:25, Random832 wrote:
Currently these functions fail if the supplied object has no len(). There are algorithms for this task that can work on any finite iterator (for example, files as a stream of lines), and the functions could fall back to these if there is no len().
I like the idea, as long as it does not add too much overhead to currently existing code.
It could be a special code path for reservoir sampling (I assume) for both functions (the first taking only one sample from the stream).
-- Bernardo Sulzbach http://www.mafagafogigante.org/ mafagafogiga...@gmail.com _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/