Add uuid7 in `uuid` module in standard library

UUID7 has better performance and collision resistance than uuid4.

Details can be found in here

1 Like

From my reading, UUID7 is currently work-in-progress and the corresponding standard is still in draft mode. As such, I don’t think adding it right now a good idea. Third party modules like this can implemented them till the standard is stable, although I don’t think that module correctly implements it right now?


For reference, there’s an issue and PR to add UUIDv6 and UUIDv7.

I think it would be good to add to the stdlib after the RFC has been accepted/published, but until then it probably makes more sense to use third-party PyPI packages. The main reason is, if there are changes to the draft RFC, these packages can be adapted and published much more quickly than Python itself.

However, it seems like the RFC is close to approval?

This November 2023 email from the Internet Engineering Steering Group says:

The IESG has approved the following document:

  • ‘Universally Unique IDentifiers (UUID)’
    (draft-ietf-uuidrev-rfc4122bis-14.txt) as Proposed Standard


Working Group Summary

The document represents a strong concurrence of a many individuals, including
many from outside the IETF community who maintain running code.

Document Quality

Yes there are a number of implementators involved, and many have implemented
the changes.

The ITU-T and the ISO published documents similiar to RFC4122 at the time,
but they have not responded to this BIS process.

So there’s a chance to get something merged before the 3.13 beta cutoff in May.


To note is that from what I can tell, the draft PR is currently wrong, because it’s out-of-date and was based on an earlier version of the spec. I might be interested in correctly implementing the current version. Should I do that on top of the existing PR and send PRs to the branch of the PR? Or should I open up a new PR?

I think the PR should be closed for now, with thanks to the author.
The open issue can track that we have the intention to add uuid7 (this is generally useful, not too controversial to implement, and the domain doesn’t have as much innovation as compression algos for example), and interested people can monitor the acceptance of the standard and poke the issue and/or this forum when it’s ready.


I marked the PR as DO-NOT-MERGE and pinged the author. If the code is basically ok and just needs minor revision (I don’t know), it should be used.

1 Like

The PR would also need tests and documentation.

The author of the issue, jgehrcke, also volunteered to contribute a PR.