From: Raymond Hettinger Date: Sat, 23 Jul 2022 23:07:17 +0000 (-0500) Subject: Compute v only when needed. (#95183) X-Git-Tag: v3.12.0a1~870 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2fbc511985f77c16c0f4a6fc6d3da9ab81a86b7;p=thirdparty%2FPython%2Fcpython.git Compute v only when needed. (#95183) --- diff --git a/Lib/random.py b/Lib/random.py index 00849bd7e732..ef0034adce5e 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