FastUUID

0.14.0 · active · verified Sun Mar 29

FastUUID provides CPython bindings to a Rust UUID library, offering an API that is functionally identical to Python's built-in `uuid` module but with significantly improved performance. It supports UUID versions v1, v3, v4, v5, and v7. The current version is 0.14.0, and it maintains an active development status with regular releases.

Warnings

Install

Imports

Quickstart

Demonstrates generating a new UUID v4, parsing an existing UUID string, and using `uuid4_bulk` for efficient generation of multiple UUIDs.

from fastuuid import uuid4, UUID, uuid4_bulk

# Generate a UUID v4
new_uuid = uuid4()
print(f"Generated UUID v4: {new_uuid}")

# Create a UUID from a string
existing_uuid_str = "12345678-1234-5678-1234-567812345678"
try:
    parsed_uuid = UUID(existing_uuid_str)
    print(f"Parsed UUID: {parsed_uuid}")
except ValueError as e:
    print(f"Error parsing UUID: {e}")

# Generate multiple UUID v4s efficiently (releases GIL)
bulk_uuids = uuid4_bulk(100)
print(f"Generated {len(bulk_uuids)} UUIDs in bulk. First one: {bulk_uuids[0]}")

view raw JSON →