8000 gh-130843: expose 48-bit timestamp for UUIDv7 by picnixz · Pull Request #131838 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-130843: expose 48-bit timestamp for UUIDv7 #131838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update Doc/library/uuid.rst
  • Loading branch information
picnixz authored Mar 28, 2025
commit 91d659fb0aa4a21c152557c32559a1fc5b06e0a2
4 changes: 2 additions & 2 deletions Doc/library/uuid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ which relays any information about the UUID's safety, using this enumeration:
- The last 48 bits of the UUID. Only relevant to version 1.

* - .. attribute:: UUID.time
- The 60-bit timestamp for version 1 and 6.
- The 48-bit timestamp for version 7.
- The 60-bit timestamp for version 1 and 6,
or the 48-bit timestamp for version 7.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the timestamp unit? Seconds? Is it using UNIX timestamp Epoch (1970-01-01 at 00:00)? You don't have to document it if it's complicated, I'm just curious.

Copy link
Member Author
@picnixz picnixz Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll repost here for posterity:

There is no "unit" here and the caller is responsible to handle it as it depends on the version. What's important is that we can recover the timestamp that was generated during UUID construction without having to do bits operations ourselves (for UUIDv7 it's easy because it's 48 first bits of the UUID but for UUIDv1 and v6, the timestamp is split into multiple chunks and those chunks are put in different places of the resulting UUID object).


* - .. attribute:: UUID.clock_seq
- The 14-bit sequence number. Only relevant to versions 1 and 6.
Expand Down
Loading
0