Skip to content

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

Merged
picnixz merged 2 commits intopython:mainfrom
picnixz:feat/uuid/uuid-v7-time-130843
Mar 31, 2025
Merged

gh-130843: expose 48-bit timestamp for UUIDv7#131838
picnixz merged 2 commits intopython:mainfrom
picnixz:feat/uuid/uuid-v7-time-130843

Conversation

@picnixz
Copy link
Copy Markdown
Member

@picnixz picnixz commented Mar 28, 2025

(skip news because the feature was added in the latest alpha and thus it wouldn't really make sense to have a separate news entry; if we can't make it in 3.14, I'll add a NEWS entry though)


📚 Documentation preview 📚: https://cpython-previews--131838.org.readthedocs.build/

Comment thread Doc/library/uuid.rst Outdated
@picnixz picnixz requested a review from hugovk March 31, 2025 09:32
Copy link
Copy Markdown
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread Doc/library/uuid.rst
* - .. attribute:: UUID.time
- The 60-bit timestamp.
- The 60-bit timestamp for version 1 and 6,
or the 48-bit timestamp for version 7.
Copy link
Copy Markdown
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
Copy Markdown
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).

@picnixz picnixz self-assigned this Mar 31, 2025
@picnixz picnixz merged commit ba11f45 into python:main Mar 31, 2025
43 checks passed
@picnixz picnixz deleted the feat/uuid/uuid-v7-time-130843 branch March 31, 2025 12:32
@bedevere-bot
Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Debian root 3.x (tier-1) has failed when building commit ba11f45.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/345/builds/10761) and take a look at the build logs.
  4. Check if the failure is related to this commit (ba11f45) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/345/builds/10761

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_ftplib.py", line 935, in tearDown
    self.server = None
ResourceWarning: unclosed <ssl.SSLSocket fd=6, family=2, type=1, proto=0, laddr=('127.0.0.1', 58787), raddr=('127.0.0.1', 58568)>
k


Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_ftplib.py", line 935, in tearDown
    self.server = None
ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=2, type=1, proto=0, laddr=('127.0.0.1', 40921), raddr=('127.0.0.1', 55662)>
k

@picnixz
Copy link
Copy Markdown
Member Author

picnixz commented Mar 31, 2025

I doubtz this has something to do with my change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants