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
26 remaining items
pythongh-139122: Apply UUID review cleanup
pythongh-139122: Fix concurrent UUID entropy refills and UUIDv7 state…
pythongh-139122: Avoid subclass module-state lookup during UUID deall…
pythongh-139122: Mark UUID testing hook as an explicit re-export
pythongh-139122: Document UUID performance improvements in What’s New
pythongh-139122: Match Python UUID prefix and brace parsing
pythongh-139122: Assert UUID type association is a module during deal…
pythongh-139122: Propagate SafeUUID lookup errors in is_safe getter
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…