Skip to main content

Logo: pUUID - Prefixed UUIDs for Python

pUUID - Prefixed UUIDs for Python with Pydantic & SQLAlchemy support.

repository mirror License: LGPLv3 pipeline status coverage report Code style: black Imports: isort

pkgversion versionsupport Downloads Week Downloads Total


pUUID - Prefixed UUIDs for Python

Raw UUIDs like 019b9a2e-9856-... are annoying to work with. They provide no context in logs, traces or bug reports and offer no safe guards against accidental ID swapping in code. pUUID provides prefixed UUIDs for python with minimal overhead and strong type guarantees.

Features

  • Human-Friendly: Immediate context with prefixed UUIDs (e.g. user_019b9a2e...).
  • Strong type guarantees: Prevent passing of a CustomerID into a payment_id field.
  • Standard Compliant: Supports all UUID versions from RFC 9562.
  • Pydantic support. (Read more)
  • SQLAlchemy support. (Read more)

Installation

# NOTE: pUUID requires python 3.14+
pip install pUUID

# For Pydantic support:
pip install 'pUUID[pydantic]'

# For SQLAlchemy support:
pip install 'pUUID[sqlalchemy]'

Usage

Define a domain-specific ID by inheriting from a versioned base:

from typing import Literal
from puuid import PUUIDv7

UserUUID = PUUIDv7[Literal["user"]]

# Generation
uid = UserUUID()
print(uid) # user_019b956e-ed25-70db-9d0a-0f30fb9047c2

# Deserialization
uid2 = UserUUID.from_string("user_019b956e-ed25-70db-9d0a-0f30fb9047c2")

Resources

Alternatives

If you only need lexicographically sortable IDs and want to build the SQLAlchemy support yourself, these two projects might be for you:

  • TypeID - pUUID supports all UUID versions because it uses Python’s standard uuid library for UUID generation, while TypeID uses a custom generator that comes with performance improvements but only supports UUIDv7. TypeID does not support SQLAlchemy out of the box.
  • UPID - UPID implements a modified version of the ULID standard, which was designed before UUIDv7 was available. UPID does not support SQLAlchemy out of the box.

Sponsor

Digon.IO GmbH Logo

Digon.IO provides dev & data end-to-end consulting for SMEs and software companies. (Website) (Technical Blog)

The sponsor logo is the property of Digon.IO GmbH. Standard trademark and copyright restrictions apply to any use outside this repository.

License

  • Library source code: Licensed under LGPLv3.

Metadata

Release files for pUUID 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pUUID 1.1.0
File Size Uploaded Provenance Actions
puuid-1.1.0.tar.gz 8.1 kB Without provenance Details for puuid-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pUUID 1.1.0
File Interpreter ABI Platform Actions
puuid-1.1.0-py3-none-any.whl Python 3 none any Details for puuid-1.1.0-py3-none-any.whl

Total release size: 17.0 kB

Release files / puuid-1.1.0.tar.gz

Download URL puuid-1.1.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5fb88174730a7f7cb1fa8ae6511437d0639113696745b67f2b1642768cf9fb42
BLAKE2b-256 checksum
How to use checksums
c91e58fc0e16ec3cebb19459ca247fe2a24409f6732d81c76f842e13b72ed53c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release files / puuid-1.1.0-py3-none-any.whl

Download URL puuid-1.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0f8f96af9d6b8c70d876e4ef3a6254194079d3dcf6b20319e233debb03bcd48
BLAKE2b-256 checksum
How to use checksums
093045ed5f93149e2bd75045b032cd558c4458c15d7f206d91c686ae9f5e9795
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Security for pUUID 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page