Ram Rachum
b0dfc75816
bpo-41773: Raise exception for non-finite weights in random.choices(). (GH-22441)
2020-09-28 18:32:10 -07:00
Raymond Hettinger
6a613f90bf
random module: Convert a "while 1" to "while True (GH-21700)
2020-08-02 12:03:32 -07:00
Raymond Hettinger
5c3270939c
bpo-41421: Algebraic simplification for random.paretovariate() (GH-21695)
2020-08-01 01:18:26 -07:00
Raymond Hettinger
ef19bad7d6
Improve code organization for the random module (GH-21161)
2020-06-25 17:03:50 -07:00
Raymond Hettinger
26a1ad1c24
Small clean-ups for the random module (GH-21038)
2020-06-22 19:38:59 -07:00
Raymond Hettinger
9db5b8d448
Minor code clean-ups (GH-20838)
2020-06-13 09:46:47 -07:00
Raymond Hettinger
81a5fc38e8
bpo-40541: Add optional *counts* parameter to random.sample() (GH-19970)
2020-05-08 07:53:15 -07:00
Raymond Hettinger
190fac99c5
bpo-40465: Deprecate the optional argument to random.shuffle(). ( #19867 )
2020-05-02 16:45:32 -07:00
Raymond Hettinger
4168f1e460
Simplify choice()'s interaction with the private _randbelow() method (GH-19831)
2020-05-01 10:34:19 -07:00
Victor Stinner
2d8757758d
bpo-40286: Remove C implementation of Random.randbytes() (GH-19797)
...
Remove _random.Random.randbytes(): the C implementation of
randbytes(). Implement the method in Python to ease subclassing:
randbytes() now directly reuses getrandbits().
2020-04-29 18:49:00 +02:00
Raymond Hettinger
4fe002045f
bpo-40325: Deprecate set object support in random.sample() (GH-19591)
2020-04-19 00:36:42 -07:00
Antoine Pitrou
75a3378810
bpo-40282: Allow random.getrandbits(0) (GH-19539)
2020-04-17 19:32:14 +02:00
Victor Stinner
9f5fe7910f
bpo-40286: Add randbytes() method to random.Random (GH-19527)
...
Add random.randbytes() function and random.Random.randbytes()
method to generate random bytes.
Modify secrets.token_bytes() to use SystemRandom.randbytes()
rather than calling directly os.urandom().
Rename also genrand_int32() to genrand_uint32(), since it returns an
unsigned 32-bit integer, not a signed integer.
The _random module is now built with Py_BUILD_CORE_MODULE defined.
2020-04-17 19:05:35 +02:00
Raymond Hettinger
041d8b48a2
bpo-38881: choices() raises ValueError when all weights are zero (GH-17362)
2019-11-23 02:22:13 -08:00
Raymond Hettinger
d0cdeaab76
bpo-32554: Deprecate hashing arbitrary types in random.seed() (GH-15382)
2019-08-22 09:19:36 -07:00
Serhiy Storchaka
2085bd0877
bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)
2019-06-01 11:00:15 +03:00
Christian Heimes
d914596a67
bpo-36559: random module: optimize sha512 import (GH-12742)
...
The random module now prefers the lean internal _sha512 module over hashlib
for seed(version=2) to optimize import time.
Signed-off-by: Christian Heimes <christian@python.org>
2019-04-10 13:18:02 -07:00
Raymond Hettinger
5382203ae1
Convert range to repeat for choices() ( #11889 )
2019-02-16 13:30:51 -08:00
Raymond Hettinger
cfd31f0af2
Be consistent about the use of from-imports in random module (GH-11837)
...
Minor code clean-up.
2019-02-13 02:04:17 -08:00
Kumar Akshay
2433a2ab70
bpo-35782: Fix error message in randrange (GH-11620)
...
https://bugs.python.org/issue35782
2019-01-21 11:19:59 -08:00
leodema
63d152232e
bpo-30561: Sync-up expovariate() and gammavariate code (GH-1934)
2018-12-23 22:54:25 -08:00
Victor Stinner
8db5b54463
bpo-35513, unittest: TextTestRunner uses time.perf_counter() (GH-11180)
...
TextTestRunner of unittest.runner now uses time.perf_counter() rather
than time.time() to measure the execution time of a test: time.time()
can go backwards, whereas time.perf_counter() is monotonic.
Similar change made in libregrtest, pprint and random.
2018-12-17 11:30:34 +01:00
Raymond Hettinger
09473ac063
Remove unnecessary and over-restrictive type check (GH-10905)
2018-12-04 14:53:14 -08:00
Raymond Hettinger
7fc633f5a5
Add comments regarding speed/space/entropy trade-offs (GH-10885)
2018-12-04 00:13:38 -08:00
Raymond Hettinger
0a18e0510a
Hoist the float conversion out of the inner loop. (GH-10430)
...
Currently, the *n* and *total* variables get converted to floats each time they are multiplied by random(). This minor tweak does the conversion just once and gets a small speedup (approx 3%).
2018-11-09 02:39:50 -08:00
Raymond Hettinger
e69cd169af
Minor code refactoring. Compute len() one fewer times on one code path. (GH-8094)
2018-07-04 15:28:20 -07:00
Raymond Hettinger
ddf7171911
bpo-24567: Random subnormal.diff ( #7954 )
...
Handle subnormal weights for choices()
2018-06-27 01:08:31 -07:00
Serhiy Storchaka
ec1622d56c
bpo-33144: Fix choosing random.Random._randbelow implementation. (GH-6563)
...
random() takes precedence over getrandbits() if defined later
in the class tree.
2018-05-08 15:45:15 +03:00
Wolfgang Maier
ba3a87aca3
bpo-33144: random.Random and subclasses: split _randbelow implementation (GH-6291)
2018-04-17 08:16:17 -07:00
Wolfgang Maier
091e95e900
bpo-33203: Ensure random.choice always raises IndexError on empty sequence (GH-6338)
2018-04-05 08:19:44 -07:00
Raymond Hettinger
132a7d7cdb
bpo-31482: Missing bytes support for random.seed() version 1 ( #3614 )
...
bpo-31482: Missing bytes support for random.seed() version 1 #3614
2017-09-17 09:04:30 -07:00
Raymond Hettinger
f5ea83f486
random_triangular: sqrt() is more accurate than **0.5 ( #3317 )
2017-09-04 16:51:06 -07:00
leodema
9f396b605e
fix comment ( #1798 )
2017-06-04 07:41:41 +01:00
Gregory P. Smith
163468a766
bpo-16500: Don't use string constants for os.register_at_fork() behavior ( #1834 )
...
Instead use keyword only arguments to os.register_at_fork for each of the scenarios.
Updates the documentation for clarity.
2017-05-29 10:03:41 -07:00
Antoine Pitrou
346cbd351e
bpo-16500: Allow registering at-fork handlers ( #1715 )
...
* bpo-16500: Allow registering at-fork handlers
* Address Serhiy's comments
* Add doc for new C API
* Add doc for new Python-facing function
* Add NEWS entry + doc nit
2017-05-27 17:50:54 +02:00
Raymond Hettinger
bb2839b680
Issue #29055 : Suppress upstream exception for random.choice()
2016-12-27 01:06:52 -08:00
Raymond Hettinger
bf87126a63
Issue 28475: Improve error message for random.sample() with k < 0. (Contributed by Francisco Couzo).
2016-11-21 14:34:33 -08:00
Raymond Hettinger
24e4239434
Fix typos
2016-11-13 00:42:56 -05:00
Raymond Hettinger
8567e58ae3
Minor code beautification
2016-11-01 22:23:11 -07:00
Raymond Hettinger
30d00e54dd
Issue #18844 : Make the various ways for specifing weights produce the same results.
2016-10-29 16:55:36 -07:00
Raymond Hettinger
9016f2864a
Issue #18844 : Make the number of selections a keyword-only argument for random.choices().
2016-09-26 21:45:57 -07:00
Raymond Hettinger
28aa4a0684
Rename weighted_choices() to just choices()
2016-09-07 00:08:44 -07:00
Raymond Hettinger
e8f1e002c6
Issue #18844 : Add random.weighted_choices()
2016-09-06 17:15:29 -07:00
Victor Stinner
e66987e626
os.urandom() now blocks on Linux
...
Issue #27776 : The os.urandom() function does now block on Linux 3.17 and newer
until the system urandom entropy pool is initialized to increase the security.
This change is part of the PEP 524.
2016-09-06 16:33:52 -07:00
Raymond Hettinger
6579502c7e
Merge
2016-09-04 11:17:48 -07:00
Raymond Hettinger
16eb827b33
Improve docs for random.seed()
2016-09-04 11:17:28 -07:00
Raymond Hettinger
2f9cc7ab0c
Minor beautification (turn nested-if into a conjunction).
2016-08-31 23:00:32 -07:00
Raymond Hettinger
112835cb3e
Merge
2016-08-31 15:01:28 -07:00
Raymond Hettinger
c7bab7cbf5
Issue #27706 : Fix regression in random.seed(somestr, version=1)
2016-08-31 15:01:08 -07:00
Raymond Hettinger
650c1c9ddd
Minor beautification
2016-06-25 05:36:42 +03:00