Commit Graph

86 Commits

Author SHA1 Message Date
Raymond Hettinger
ffd2a4215a Issue 9816: Random.jumpahead(n) didn't work well for small values of n. 2010-09-10 10:47:22 +00:00
Raymond Hettinger
34e0de135d Remove outdated XXX comment. Mapping support was removed for 3.x. 2010-09-06 22:54:24 +00:00
Raymond Hettinger
2c0cdca564 Issue 6261: Clarify behavior of random.uniform(). 2009-06-11 23:14:53 +00:00
Mark Dickinson
e6dc53120d Issue #4869: clarify documentation for random.expovariate. 2009-01-07 17:48:33 +00:00
Benjamin Peterson
f2eb2b44fc getrandombits is actually getrandbits 2008-07-30 13:46:53 +00:00
Raymond Hettinger
c4f7bab0a0 Adopt Nick's suggestion for useful default arguments.
Clean-up floating point issues by adding true division and float constants.
2008-03-23 19:37:53 +00:00
Raymond Hettinger
bbc50eafe5 Issue 1681432: Add triangular distribution the random module. 2008-03-23 13:32:32 +00:00
Martin v. Löwis
6b449f4f2b Issue #1727780: Support loading pickles of random.Random objects created
on 32-bit systems on 64-bit systems, and vice versa. As a consequence
of the change, Random pickles created by Python 2.6 cannot be loaded
in Python 2.5.
2007-12-03 19:20:02 +00:00
Raymond Hettinger
1b0ce85271 SF# 1635892: Fix docs for betavariate's input parameters . 2007-01-19 18:07:18 +00:00
Raymond Hettinger
94547f7646 Bug #1590891: random.randrange don't return correct value for big number
Needs to be backported.
2006-12-20 06:42:06 +00:00
Tim Peters
0e1159583c shuffle() doscstring: Removed warning about sequence length
versus generator period.  While this was a real weakness of the
older WH generator for lists with just a few dozen elements,
and so could potentially bite the naive ;-), the Twister should
show excellent behavior up to at least 600 elements.

Module docstring:  reflowed some jarringly short lines.
2006-06-10 22:51:45 +00:00
Tim Peters
c17976e983 Another crack at bug #1460340: make random.sample(dict)
work, this time by ugly brute force.
2006-04-01 00:26:53 +00:00
Raymond Hettinger
3c3346daa9 SF bug #1460340: random.sample can raise KeyError
Fix the hit and miss style of testing for sets and dicts.
2006-03-29 09:13:13 +00:00
Tim Peters
9e34c04732 Whitespace normalization (via reindent.py). 2005-08-26 15:20:46 +00:00
Raymond Hettinger
91e27c253c Implement random.sample() using sets instead of dicts. 2005-08-19 01:36:35 +00:00
Raymond Hettinger
42406e6f27 SF patch #1191489: Simplify logic in random.py 2005-04-30 09:02:51 +00:00
Raymond Hettinger
362b929222 Removed unused line. 2005-01-03 07:33:16 +00:00
Raymond Hettinger
ffdb8bb99c Use floor division operator. 2004-09-27 15:29:05 +00:00
Raymond Hettinger
23f1241dc6 SF #1027105: HardwareRandom should be renamed OSRandom
Renamed the new generator at Trevor's recommendation.
The name HardwareRandom suggested a bit more than it
delivered (no radioactive decay detectors or such).
2004-09-13 22:23:21 +00:00
Raymond Hettinger
c1c43cad63 Fulfill Martin's request to use try/except rather than a "look before
you leap" approach.  Makes the early call to os.urandom() unnecessary.
2004-09-05 00:00:42 +00:00
Raymond Hettinger
bdbdfd731d SF bug #1022010: Import random fails
* trap NotImplementedError raised by os.urandom calls when not available
  on a particular system.
2004-09-03 19:09:22 +00:00
Tim Peters
7c2a85b2d4 HardwareRandom: Go back to multiplying by 2**-BPF instead of using
ldexp.  Both methods are exact, and return the same results.  Turns out
multiplication is a few (but just a few) percent faster on my box.
They're both significantly faster than using struct with a Q format
to convert bytes to a 64-bit long (struct.unpack() appears to lose due
to the tuple creation/teardown overhead), and calling _hexlify is
significantly faster than doing bytes.encode('hex').  So we appear to
have hit a local minimum (wrt speed) here.
2004-08-31 02:19:55 +00:00
Raymond Hettinger
3fa19d7ff8 Take advantage of the math library's ldexp for assembling a float by
components without division and without roundoff error for properly
sized mantissas (i.e. on systems with 53 or more mantissa bits per
float).  Eliminates the previous implementation's rounding bias as
aptly demonstrated by Tim Peters.
2004-08-31 01:05:15 +00:00
Raymond Hettinger
356a4599ac Teach the random module about os.urandom().
* Use it for seeding when it is available.
* Provide an alternate generator based on it.
2004-08-30 06:14:31 +00:00
Raymond Hettinger
5dae505bbd Fix typo in comment. 2004-06-07 02:07:15 +00:00