MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _random

Method _random

bson/objectid.py:173–179  ·  view source on GitHub ↗

Generate a 5-byte random number once per process.

(cls)

Source from the content-addressed store, hash-verified

171
172 @classmethod
173 def _random(cls) -> bytes:
174 """Generate a 5-byte random number once per process."""
175 pid = os.getpid()
176 if pid != cls._pid:
177 cls._pid = pid
178 cls.__random = _random_bytes()
179 return cls.__random
180
181 @property
182 def binary(self) -> bytes:

Callers 3

oid_generated_on_processFunction · 0.80
__init__Method · 0.80

Calls 1

_random_bytesFunction · 0.85

Tested by 1