def _set_uuid(self, uuid):
if uuid is None:
# UUID generation is expensive. Using FastUUID instead of the built
# in UUID methods increases Messages that can be instantiated per
# second from ~25,000 to ~185,000. Not generating UUIDs at all
# increases the throughput further still to about 730,000 per
# second.
uuid = self._fast_uuid.uuid4()
elif len(uuid) != 16:
raise TypeError(
"UUIDs should be exactly 16 bytes. Conforming UUID's can be "
"generated with `import uuid; uuid.uuid4().bytes`."
)
self._uuid = uuid
评论列表
文章目录