MCPcopy Create free account
hub / github.com/rthalley/dnspython / random_between

Method random_between

dns/entropy.py:94–107  ·  view source on GitHub ↗
(self, first: int, last: int)

Source from the content-addressed store, hash-verified

92 return self.random_16() * 65536 + self.random_16()
93
94 def random_between(self, first: int, last: int) -> int:
95 size = last - first + 1
96 if size > 4294967296:
97 raise ValueError("too big")
98 if size > 65536:
99 rand = self.random_32
100 max = 4294967295
101 elif size > 256:
102 rand = self.random_16
103 max = 65535
104 else:
105 rand = self.random_8
106 max = 255
107 return first + size * rand() // (max + 1)
108
109
110pool = EntropyPool()

Callers 4

test_poolMethod · 0.95
betweenFunction · 0.80
badMethod · 0.80

Calls

no outgoing calls

Tested by 3

test_poolMethod · 0.76
badMethod · 0.64