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

后端 未结 6 1276
情话喂你
情话喂你 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条回答
  •  Happy的楠姐
    2020-12-07 07:59

    Perhaps something that's not been mentioned is that of locality.

    A MAC address or time-based ordering (UUID1) can afford increased database performance, since it's less work to sort numbers closer-together than those distributed randomly (UUID4) (see here).

    A second related issue, is that using UUID1 can be useful in debugging, even if origin data is lost or not explicitly stored (this is obviously in conflict with the privacy issue mentioned by the OP).

提交回复
热议问题