python / cpython

The Python programming language
https://www.python.org
Other
63.41k stars 30.36k forks source link

Add UUID version 6 and 7 to stdlib (Lib/uuid.py) once RFC 4122 becomes updated #102461

Closed jgehrcke closed 4 months ago

jgehrcke commented 1 year ago

An update to RFC 4122 is well underway: https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/ The last version (as of the time of writing this) is from 16 February 2023.

Editorial work seems to be happening here: https://github.com/ietf-wg-uuidrev/rfc4122bis High-level updates are communicated here: https://github.com/uuid6/uuid6-ietf-draft/issues/122

Among others, this updated standard introduces UUID versions 6 and 7. The Internet community seems to be excited about those. I trust that it's rather uncontroversial that at least those two should be added to Python's standard library once the standard is complete. But of course we should collect opinions about that idea here.

Prior art:

terryjreedy commented 1 year ago

uuid.py is actively maintained, but no one has claimed it at https://devguide.python.org/core-developers/experts/.

@jgehrcke Are you in a position to submit a PR at the appropriate time?

@tiran Does your security interest include this module? You patched it last July.

jgehrcke commented 1 year ago

@terryjreedy I think so, and I'd love to! Maybe @orsenthil can also help me with that (hello :wave:).

sergeyprokhorenko commented 9 months ago

I recommend using the following implementations as a basis: JavaScript Rust PostgreSQL Go language with openssl-rand or secrets.randbits (try the benchmark) for better performance.

Segment length, bits Field in RFC Segment content
48 unix_ts_ms Timestamp
4 ver Version
1 rand_a Counter segment initialized to zero
11 rand_a Counter segment initialized with a pseudorandom number
2 var Variant
30 rand_b Counter segment initialized with a pseudorandom number
32 rand_b UUIDv7 segment filled with a pseudorandom number
hugovk commented 9 months ago

For reference, see discussion at https://discuss.python.org/t/add-uuid7-in-uuid-module-in-standard-library/44390.

nineteendo commented 6 months ago

It has landed: https://www.rfc-editor.org/rfc/rfc9562

hugovk commented 5 months ago

@terryjreedy I think so, and I'd love to! Maybe @orsenthil can also help me with that (hello 👋).

@jgehrcke Hi, it's been a while, would you like to work on this for 3.14?

hugovk commented 4 months ago

Let's close this as a duplicate of the older https://github.com/python/cpython/issues/89083, which also mentions UUIDv8.