You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UUID is one of the key types, used in pretty much every modern application. And its getting even more widespread as using auto-incremented IDs in databases isn't ideal in sharded/distributed databases.
Python's UUID implementation is quite slow compared to NodeJS/Bun and other fast runtimes. This is fixable by implementing the type in C, which it should be, as it's one of the most fundamental types.
For context, I originally observed our uuid being slow when I first implemented gel-python driver years ago. It was 50% slower than its JS counterpart on a macro benchmark where UUIDs were only 10-30% of the total data, despite gel-python using C to accelerate its protocol parsing and network code. I later heard complaints about slow uuid from FastAPI core developers and other people in the ecosystem.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
Not really. But I figured this is non-controversial enough that I can give it a spin. A PR will follow shortly.
As the one who implemented v6, v7, v8 and fixed v1, I also support this idea. I decided not to write the implementation in C first so that we match the RFC quite easily but making UUID faster was on my todolist (so thanks for taking up the task)
Activity
Issue python#139122: Reimplement base UUID type, uuid4(), and uuid7()…
Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
corona10 commentedon Sep 18, 2025
I agree with this issue, as many people are starting to use UUIDs as primary keys in databases. This will definitely improve performance in Python.
picnixz commentedon Sep 18, 2025
As the one who implemented v6, v7, v8 and fixed v1, I also support this idea. I decided not to write the implementation in C first so that we match the RFC quite easily but making UUID faster was on my todolist (so thanks for taking up the task)
[-]Speedup uuid[/-][+]Implement UUID functions and type in C[/+]Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
pythongh-139122: implement UUIDv7 generation in C
34 remaining items
pythongh-139122: Honor subclass string conversion in UUID repr
pythongh-139122: Normalize line endings in UUID review suggestions
pythongh-139122: Test UUID state restoration with frozendict
pythongh-139122: Use shared hex conversion helper for UUID.hex
pythongh-139122: Format UUIDs directly into the result string
pythongh-139122: Narrow UUID exception assertions and clean up test s…
gh-139122: Reimplement base UUID type, uuid4(), and uuid7() in C (#13…
pythongh-139122: Implement uuid6 in C with OS entropy and cached node…
picnixz commentedon Oct 22, 2026
cf69000: UUIDv7 is now implemented in C and boosts 30x performance. UUIDv4 are also implemented.
pythongh-139122: Defer UUIDv6 benchmark executor import until execution
pythongh-139122: Use time hooks in UUIDv6 tests
pythongh-139122: Align UUIDv6 hook arguments
pythongh-139122: Add node hooks for UUIDv6 tests
pythongh-139122: Keep UUIDv6 benchmark in PR description