UUID v9
Fast, lightweight, zero-dependency Python implementation of UUID version 9
The v9 UUID supports both sequential (time-based) and non-sequential (random) UUIDs with an optional prefix of up to four bytes, an optional checksum, and sufficient randomness to avoid collisions. It uses the UNIX timestamp for sequential UUIDs and CRC-8 for checksums. The version can be added if desired, but is omitted by default.
To learn more about UUID v9, please visit the website: https://uuidv9.jhunt.dev
Installation
Install UUID v9 from PyPI.
python3 -m pip install uuid-v9
Usage
from uuid_v9 import uuidv9, is_valid_uuidv9
ordered_id = uuidv9()
prefixed_ordered_id = uuidv9(prefix='a1b2c3d4')
unordered_id = uuidv9(timestamp=False)
prefixed_unordered_id = uuidv9(prefix='a1b2c3d4', timestamp=False)
ordered_id_with_checksum = uuidv9(checksum=True)
ordered_id_with_version = uuidv9(checksum=True, version=True)
ordered_id_with_compatibility = uuidv9(legacy=True)
const is_valid = validate_uuidv9(ordered_id)
const is_valid_with_checksum = validate_uuidv9(ordered_id_with_checksum, True)
const is_valid_with_version = validate_uuidv9(ordered_id_with_version, True, True)
const is_valid_with_compatibility = validate_uuidv9(ordered_id_with_compatibility, True, '1')
Command Line Usage
python3 uuid_v9.py
python3 uuid_v9.py --prefix 'a1b2c3d4' # add a prefix
python3 uuid_v9.py --random # omit the timestamp
python3 uuid_v9.py --checksum # add a CRC-8 checksum
python3 uuid_v9.py --version # add version 9 identifiers
python3 uuid_v9.py --legacy # legacy mode (see Backward Compatibility below)
Backward Compatibility
Some UUID validators check for specific features of v1 or v4 UUIDs. This causes some valid v9 UUIDs to appear invalid. Three possible workarounds are:
- Use the built-in validator (recommended)
- Use compatibility mode*
- Bypass the validator (not recommended)
*Legacy mode adds version and variant digits to immitate v1 or v4 UUIDs depending on the presence of a timestamp.
License
This project is licensed under the MIT License.
<><
Metadata
Release files for uuid-v9 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uuid_v9-1.0.0.tar.gz | 4.9 kB | Without provenance | Details for uuid_v9-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uuid_v9-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for uuid_v9-1.0.0-py3-none-any.whl |
Total release size: 9.5 kB
Release files / uuid_v9-1.0.0.tar.gz
| Download URL | uuid_v9-1.0.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70a19b17f79255bf5c36895b4056758ea0ef3e883db813bf1c06ed36d47afad3
|
|
BLAKE2b-256 checksum How to use checksums |
657942041ecae82bc03991c71d548d1ee4908d571ecd7acca423d88273e561f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / uuid_v9-1.0.0-py3-none-any.whl
| Download URL | uuid_v9-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b9139780c4ed34b6219c0d35171c8f5c63feb3ec6ed3b3d8d5a429912c037b0
|
|
BLAKE2b-256 checksum How to use checksums |
e86a032c305e0432ac63be882b80b742a4951c4da6e74ecce01fbdfd8fb5db38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Security for uuid-v9 1.0.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.