[Python-ideas] Shuffled

Danilo J. S. Bellini danilo.bellini at gmail.com
Wed Sep 7 23:33:42 EDT 2016


Nice to know about random.sample! =)

I think what OP said can then be reduced to having the default k in
random.sample to be the iterable size. The existance of random.sample is a
very strong argument against "shuffled", and the only "feature" shuffled
would have that random.sample doesn't have is that default size.

You cannot sort a sequence lazily
>
You can, but it probably wouldn't be efficient if you need all the values.
On the other hand, if you need just the 3 smaller values of a huge list...
well, that's another topic.


2016-09-08 0:28 GMT-03:00 Nick Coghlan <ncoghlan at gmail.com>:

> On 8 September 2016 at 13:23, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> > Beyond that practical benefit, if you want
> > random-sampling-with-replacement, then "map(random.choice, container)"
>
> Oops, that was supposed to be "map(random.choice,
> itertools.repeat(container))".
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
>



-- 
Danilo J. S. Bellini
---------------
"*It is not our business to set up prohibitions, but to arrive at
conventions.*" (R. Carnap)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160908/18dbf089/attachment.html>


More information about the Python-ideas mailing list