UUID6

2025.0.1 · active · verified Thu Apr 09

The uuid6 library provides new time-based UUID formats (v6, v7, v8) that are optimized for use as database keys, offering better performance and sequential ordering than traditional UUIDv1. As of version 2025.0.0, the project transitioned from Calendar Versioning (YYYY.MM.DD) to Semantic Versioning (MAJOR.MINOR.PATCH) and maintains a frequent release cadence.

Warnings

Install

Imports

Quickstart

Generates a UUIDv6 and UUIDv7, demonstrating basic usage and object instantiation.

from uuid6 import uuid6, uuid7, UUID

# Generate a UUIDv6
my_uuid6 = uuid6()
print(f"Generated UUIDv6: {my_uuid6}")
print(f"Type: {type(my_uuid6)}")

# Generate a UUIDv7 (millisecond granularity)
my_uuid7 = uuid7()
print(f"Generated UUIDv7: {my_uuid7}")

# You can also instantiate UUID objects from strings
uuid_obj = UUID("018e612f-8700-613d-88f5-93717d2f9d6c")
print(f"UUID object from string: {uuid_obj}")

view raw JSON →