ULID-transform

2.2.0 · active · verified Wed Apr 15

ULID-transform is a high-performance Python library designed for creating and transforming ULIDs (Universally Unique Lexicographically Sortable Identifiers). It provides efficient generation of ULIDs and seamless conversion between ULIDs and UUIDs. The library is currently at version 2.2.0 and maintains an active release cadence, frequently incorporating performance enhancements and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate a new ULID and perform conversions between ULID strings and UUID objects using the core functions of the `ulid-transform` library.

import uuid
from ulid_transform import generate_ulid, ulid_to_uuid, uuid_to_ulid

# Generate a new ULID
new_ulid = generate_ulid()
print(f"Generated ULID: {new_ulid}")

# Convert a ULID string to a UUID object
some_ulid_str = "01ARZ3NDEKTSV4RRFFQ69G5FAV"
converted_uuid = ulid_to_uuid(some_ulid_str)
print(f"ULID '{some_ulid_str}' converted to UUID: {converted_uuid}")

# Convert a UUID object (or string) to a ULID string
some_uuid_obj = uuid.uuid4()
converted_ulid = uuid_to_ulid(str(some_uuid_obj))
print(f"UUID '{some_uuid_obj}' converted to ULID: {converted_ulid}")

view raw JSON →