UUID7 Standard (pypi: uuid7-standard)

1.1.0 · active · verified Thu Apr 16

This library provides a Python implementation for generating and manipulating UUIDs adhering to the final UUID version 7 standard, ensuring time-ordered identifiers. It explicitly distinguishes itself from the older `uuid7` package on PyPI, which was based on an earlier draft of the standard. The current version is 1.1.0, and it follows a release cadence driven by bug fixes and minor improvements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate a new UUIDv7 using `generate_uuid()` and how to parse an existing UUIDv7 string back into a `UUID7` object.

from uuid7_standard import generate_uuid, UUID7

# Generate a UUIDv7 object
new_uuid = generate_uuid()
print(f"Generated UUIDv7 object: {new_uuid}")
print(f"Type: {type(new_uuid)}")
print(f"UUIDv7 as string: {str(new_uuid)}")

# You can also parse a UUIDv7 string into a UUID7 object
# Example valid UUIDv7 string (replace with your actual UUID if needed)
uuid_str = str(new_uuid) # Or use a known valid UUIDv7 string
try:
    parsed_uuid = UUID7(uuid_str)
    print(f"Parsed UUIDv7 object: {parsed_uuid}")
    print(f"Timestamp of parsed UUID: {parsed_uuid.datetime}")
except ValueError as e:
    print(f"Error parsing UUID: {e}")

view raw JSON →