From a2fbc511985f77c16c0f4a6fc6d3da9ab81a86b7 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 23 Jul 2022 18:07:17 -0500 Subject: Compute v only when needed. (#95183) --- Lib/random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/random.py b/Lib/random.py index 00849bd..ef0034a 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -787,7 +787,6 @@ class Random(_random.Random): while True: u = random() - v = random() u -= 0.5 us = 0.5 - _fabs(u) k = _floor((2.0 * a / us + b) * u + c) @@ -796,6 +795,7 @@ class Random(_random.Random): # The early-out "squeeze" test substantially reduces # the number of acceptance condition evaluations. + v = random() if us >= 0.07 and v <= vr: return k -- cgit v0.12