Comment by nitwit005

15 hours ago

The Python version simply forces the timestamp forward if needed to preserve ordering:

  if timestamp_ms < _last_timestamp_v7:
    timestamp_ms = _last_timestamp_v7 + 1

https://github.com/python/cpython/blob/8d119208074fef0f652f1...

But if you did want "monotonically increasing IDs", as the article suggests, that is what you want.

This is perfect if you only have one machine and the process never restarts. But then if you only have one machine you don’t realistically need uuid identifiers.

  • This is why the oldschool UUIDv1 spec specifies initializing the sequence value at a random number:

    “12.4.4 — The Clock Sequence shall be originally (that is, once in the lifetime of a system producing UUIDs) initialized to a random number that is not derived from the Node value. NOTE – This is in order to minimize the correlation across systems, providing maximum protection”

So you can't generate more than 1000 UUIDs per second without skewing timestamp portion? That's not a lot. Bulk imports often require a lot more inserts.

  • Reading that code there's a 48-bit counter used for each millisecond, so ~281 quadrillion UUIDs per second.