When should I use uuid.uuid1() vs. uuid.uuid4() in python?

后端 未结 6 1285
情话喂你
情话喂你 2020-12-07 07:43

I understand the differences between the two from the docs.

uuid1():
Generate a UUID from a host ID, sequence number, and the current time

<

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 08:05

    One thing to note when using uuid1, if you use the default call (without giving clock_seq parameter) you have a chance of running into collisions: you have only 14 bit of randomness (generating 18 entries within 100ns gives you roughly 1% chance of a collision see birthday paradox/attack). The problem will never occur in most use cases, but on a virtual machine with poor clock resolution it will bite you.

提交回复
热议问题