File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -751,6 +751,15 @@ def uuid6(node=None, clock_seq=None):
751751 timestamp = _last_timestamp_v6 + 1
752752 _last_timestamp_v6 = timestamp
753753 if clock_seq is None :
754+ # If the caller does not specify a clock sequence, we may assume that
755+ # sequentiality within the same 60-bit timestamp is less important
756+ # than unpredictability. In particular, by using a randomized clock
757+ # sequence, we indirectly slow down the next call, thereby allowing
758+ # the next 60-bit timestamp to be distinct.
759+ #
760+ # Stated otherwise, it is unlikely that two UUIDs are generated within
761+ # the same 100-ns interval since constructing a UUID object takes more
762+ # than 100 ns.
754763 import random
755764 clock_seq = random .getrandbits (14 ) # instead of stable storage
756765 time_hi_and_mid = (timestamp >> 12 ) & 0xffff_ffff_ffff
You can’t perform that action at this time.
0 commit comments