- Very fast UUID v7 generator (see benchmarks)
Using pip:
pip install uuid7-rs
Using uv:
uv pip install uuid7-rsimport uuid7_rs
print(uuid7_rs.uuid7()) # 019ea835-f42a-7dd5-8fc3-9f91aab5a95e
# or
print(uuid7_rs.compat.uuid7()) # 019ea835-f42b-7dbd-a198-1b6d65ef5eb4Compatibility with Python uuid.UUID
In some cases, for example if you are using Django, you might
need uuid.UUID instances to be returned
from the standard-library uuid, not a custom UUID class.
In that case you can use the uuid7-rs.compat which comes with a performance penalty
in comparison with the uuid7-rs default behaviour, but is still faster than the standard-library.
import uuid7_rs.compat as uuid
# make a random UUID
print(repr(uuid.uuid7()))
# UUID('019d1ab3-f95a-79df-b868-56fe41c33af3')