gh-130843: add UUIDv7 timestamp recipes #132154
                
     Merged
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Note: historically, Python (and Rust) uses a local clock instead of querying exact UTC time. Now the RFC says:
So I think it's a good idea to indicate that we're actually using
time.time()and nottime.gmtime()when computing the timestamps. Both implementation choices are RFC compliant, and using a local time seems to be what other languages do (if I'm wrong, please correct me as I'm no Rust expert).Note: if A in timezone$z_A$  generates a UUIDv7 at time $t_A$ , and gives it to B in timezone $z_B$ , then unless B knows $z_A$ , they won't be able to know about $t_A$  as 
u.timewould give the timestamp since Unix epoch with a "hidden" offset. But I'm not comfortable with Python being the only one that is actually generating UUIDv7 objects that are UTC-based and not local-time. For UUIDv1, I prefer not to change anything and UUIDv6 is meant to be compatible with UUIDv1, so I shouldn't change one without changing the other. UUIDv7 could be using UTC-based times (namely the timestamp would be extracted usingtime.time_ns() - offsetbut I don't know if Python should be the only one doing it...)📚 Documentation preview 📚: https://cpython-previews--132154.org.readthedocs.build/