mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Compute v only when needed. (#95183)
This commit is contained in:
parent
23f6944c37
commit
a2fbc51198
1 changed files with 1 additions and 1 deletions
|
@ -787,7 +787,6 @@ class Random(_random.Random):
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
u = random()
|
u = random()
|
||||||
v = random()
|
|
||||||
u -= 0.5
|
u -= 0.5
|
||||||
us = 0.5 - _fabs(u)
|
us = 0.5 - _fabs(u)
|
||||||
k = _floor((2.0 * a / us + b) * u + c)
|
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 early-out "squeeze" test substantially reduces
|
||||||
# the number of acceptance condition evaluations.
|
# the number of acceptance condition evaluations.
|
||||||
|
v = random()
|
||||||
if us >= 0.07 and v <= vr:
|
if us >= 0.07 and v <= vr:
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue