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
Perf: Intern Result-Field Dict Keys, and Build UUIDs Without the Pyth…
Issue #pythongh-139122: Reimplement base UUID type, uuid4(), and uuid…
pythongh-139122: Fix UUID subclass allocation and freelist type owner…
pythongh-139122: Match UUID state restoration mapping semantics
pythongh-139122: Fix UUID time hook error handling and reference updates
pythongh-139122: Align C UUID constructor inputs with Python
pythongh-139122: Make UUID narrowing and entropy lock requirements ex…
pythongh-139122: Preserve UUID fields length errors
pythongh-139122: Clarify version-specific UUID layouts
pythongh-139122: Apply UUID review cleanup