]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
SF bug #801342: Bug (documentation or real, your choice) in random.sample.
authorRaymond Hettinger <python@rcn.com>
Fri, 5 Sep 2003 21:40:30 +0000 (21:40 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 5 Sep 2003 21:40:30 +0000 (21:40 +0000)
commit0b0aae087a3e3bb9fb109454f6deb2ab171f7eba
tree96e86238494ff9bc802ef007f7610f9a2263c42a
parent046595e496678e65e88905f64072256c4b716f2f
SF bug #801342:  Bug (documentation or real, your choice) in random.sample.

random.sample() uses one of two algorithms depending on the ratio of the
sample size to the population size.  One of the algorithms accepted any
iterable population argument so long as it defined __len__().  The other
had a stronger requirement that the population argument be indexable.

While it met the documentation specifications which insisted that the
population argument be a sequence, it made random.sample() less usable
with sets.  So, the second algorithm was modified to coerce non-indexable
iterables and dictionaries into a tuple before proceeding.
Lib/random.py
Lib/test/test_random.py
Misc/NEWS