[Python-checkins] r43512 - in python/trunk: Lib/random.py Lib/test/test_random.py Misc/NEWS (original) (raw)

tim.peters python-checkins at python.org
Sat Apr 1 02:26:54 CEST 2006


Author: tim.peters Date: Sat Apr 1 02:26:53 2006 New Revision: 43512

Modified: python/trunk/Lib/random.py python/trunk/Lib/test/test_random.py python/trunk/Misc/NEWS Log: Another crack at bug #1460340: make random.sample(dict) work, this time by ugly brute force.

Modified: python/trunk/Lib/random.py

--- python/trunk/Lib/random.py (original) +++ python/trunk/Lib/random.py Sat Apr 1 02:26:53 2006 @@ -285,6 +285,15 @@ large population: sample(xrange(10000000), 60) """

@@ -304,7 +313,9 @@ setsize = 21 # size of a small set minus size of an empty list if k > 5: setsize += 4 ** _ceil(_log(k * 3, 4)) # table size for big sets

@@ -320,10 +331,10 @@ j = _int(random() * n) selected_add(j) result[i] = population[j]

-------------------- real-valued distributions -------------------

Modified: python/trunk/Lib/test/test_random.py

--- python/trunk/Lib/test/test_random.py (original) +++ python/trunk/Lib/test/test_random.py Sat Apr 1 02:26:53 2006 @@ -93,12 +93,28 @@ self.gen.sample(set(range(20)), 2) self.gen.sample(range(20), 2) self.gen.sample(xrange(20), 2)

Modified: python/trunk/Misc/NEWS

--- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Apr 1 02:26:53 2006 @@ -489,6 +489,11 @@ Library

+- Bug #1460340: random.sample(dict) failed in various ways. Dicts + aren't officially supported here, and trying to use them will probably + raise an exception some day. But dicts have been allowed, and "mostly + worked", so support for them won't go away without warning. + - Bug #1445068: getpass.getpass() can now be given an explicit stream argument to specify where to write the prompt.


More information about the Python-checkins mailing list