Skip to content

Commit a2fbc51

Browse files
authored
Compute v only when needed. (#95183)
1 parent 23f6944 commit a2fbc51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/random.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ def binomialvariate(self, n=1, p=0.5):
787787
while True:
788788

789789
u = random()
790-
v = random()
791790
u -= 0.5
792791
us = 0.5 - _fabs(u)
793792
k = _floor((2.0 * a / us + b) * u + c)
@@ -796,6 +795,7 @@ def binomialvariate(self, n=1, p=0.5):
796795

797796
# The early-out "squeeze" test substantially reduces
798797
# the number of acceptance condition evaluations.
798+
v = random()
799799
if us >= 0.07 and v <= vr:
800800
return k
801801

0 commit comments

Comments
 (0)