Compute v only when needed. (#95183)

This commit is contained in:
Raymond Hettinger 2022-07-23 18:07:17 -05:00 committed by GitHub
parent 23f6944c37
commit a2fbc51198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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