<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Apr 13, 2016 at 12:45 PM Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Apr 13, 2016 at 2:47 AM, Rob Cliffe <<a href="mailto:rob.cliffe@btinternet.com" target="_blank">rob.cliffe@btinternet.com</a>> wrote:<br>
> Isn't there an inconsistency that random.sample caters to a set by<br>
> converting it to a tuple, but random.choice doesn't?<br>
<br>
Perhaps because the use cases are different? Over the years I've<br>
learned that inconsistencies aren't always signs of sloppy thinking --<br>
they may actually point to deep issues that aren't apparently on the<br>
surface.<br>
<br>
I imagine the typical use case for sample() to be something that<br>
samples the population once and then does something to the sample; the<br>
next time sample() is called the population is probably different<br>
(e.g. the next lottery has a different set of players).<br>
<br>
But I imagine a fairly common use case for choice() to be choosing<br>
from the same population over and over, and that's exactly the case<br>
where the copying implementation you're proposing would be a small<br>
disaster.<br></blockquote><div><br></div><div>Repeated random sampling from the same population is a common use case ("bootstrapping"). Perhaps the oversight was *allowing* sets as input into random.sample.</div></div></div>