logoalt Hacker News

nitwit005 • yesterday at 6:16 PM • 2 replies • view on HN

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.


Replies

dpark • yesterday at 7:11 PM

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.

➕ show 1 reply
vbezhenar • yesterday at 11:06 PM

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.