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)
  • FastAPI support (just use Pydantic as you want)
  • 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

class UserUUID(PUUIDv7[Literal["user"]]): ...

# Generation
uid = UserUUID.factory()
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 2.0.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 2.0.0
File Size Uploaded
puuid-2.0.0.tar.gz 7.4 kB Details

Built distribution (wheel)

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

Total release size: 15.5 kB

Release files / puuid-2.0.0.tar.gz

Download URL puuid-2.0.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
622b5f0f7844d705983794d446d4b0b860c62e3c8b377832b343db5260384393
BLAKE2b-256 checksum
How to use checksums
2fef53fb6747b7e88ee96ebdcabdfbbb3acbb4e3775d3b8ccce6bafa6aeeb9b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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

Download URL puuid-2.0.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
639bed4929e8b1cc4af96cf9114e1a270983f2426929c3176152c336c867e943
BLAKE2b-256 checksum
How to use checksums
cb5d2eb318ef85165dd2cb1b4ce847e1e4379a5e60776675d221b9b24762199c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

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