Is python uuid1 sequential as timestamps?

后端 未结 5 1243
孤城傲影
孤城傲影 2020-12-19 00:34

Python docs states that uuid1 uses current time to form the uuid value. But I could not find a reference that ensures UUID1 is sequential.

>>> impor         


        
5条回答
  •  无人及你
    2020-12-19 01:16

    From the python UUID docs:

    Generate a UUID from a host ID, sequence number, and the current time. If node is not given, getnode() is used to obtain the hardware address. If clock_seq is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen.

    From this, I infer that the MAC address is first, then a (possibly random) sequence number, then the current time. So I would not expect these to be guaranteed to be monotonically increasing, even for UUIDs generated by the same machine/process.

提交回复
热议问题