]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Compute v only when needed. (#95183)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Sat, 23 Jul 2022 23:07:17 +0000 (18:07 -0500)
committerGitHub <noreply@github.com>
Sat, 23 Jul 2022 23:07:17 +0000 (18:07 -0500)
Lib/random.py

index 00849bd7e732fb3d9fa3cb2c8157a411506865a0..ef0034adce5e7cd9cb02a2ef159fe7f60a4afab8 100644 (file)
@@ -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