Skip to main content

An ultra-fast, lightweight, zero-dependency Python implementation of the UUID v9 proposal.

Project description

UUID v9

An ultra-fast, lightweight, zero-dependency Python implementation of the UUID v9 proposal. The proposed UUID v9 format allows generating both time-based sequential and random non-sequential IDs with an optional prefix of up to 8 hexadecimal characters, an optional version identifier, an optional checksum, and sufficient randomness to avoid collisions.

Installation

Install UUID v9 from PyPI.

python3 -m pip install uuid-v9

Usage

from uuid_v9 import uuid, is_uuidv9, is_uuid

ordered_id = uuid()
prefixed_ordered_id = uuid('a1b2c3d4') # up to 8 hexadecimal characters
unordered_id = uuid('', False)
prefixed_unordered_id = uuid('a1b2c3d4', False)
ordered_id_without_version = uuid('', True, False)
ordered_id_with_checksum = uuid('', True, True, True)

const is_valid_v9 = is_uuidv9(ordered_id, true) # UUID v9 validator with checksum
const is_valid = is_uuid(ordered_id_without_version) # generic UUID validator

Command Line

python3 uuid_v9.py
python3 uuid_v9.py --prefix 'a1b2c3d4'
python3 uuid_v9.py --unordered
python3 uuid_v9.py --noversion
python3 uuid_v9.py --checksum

Note

Some UUID validators will not recognize v9 as a valid UUID even though it is. Three possible solutions are:

  1. Use the included validator (recommended)
  2. Bypass the validator (not recommended)
  3. Substitute the version digit for an earlier version that will pass (not recommended)

Here is the UUID v9 format: xxxxxxxx-xxxx-9xxx-xxxx-xxxxxxxxxxxy

x = 0-9a-f (prefix, timestamp, random) 9 = version y = checksum (optional)

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uuid-v9-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

uuid_v9-0.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file uuid-v9-0.0.1.tar.gz.

File metadata

  • Download URL: uuid-v9-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for uuid-v9-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8a9ea31e2f534eead81434a754346c8f869b6efb8b55b9468ca713fa6ec9c1a7
MD5 91646e39401a78cf2ed9aa286da230a7
BLAKE2b-256 99ea7b04bed820f856dae2270d5dc41b4e7ed8f3aab687a2c0eebd592b5012f1

See more details on using hashes here.

File details

Details for the file uuid_v9-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: uuid_v9-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for uuid_v9-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d040e7f6ffb08e9ccc44c87af116e7f60b6c621620afc468d4e9c35c2afdef6c
MD5 5c75d71c033528786d675d3dbfb35996
BLAKE2b-256 5a48ac1e04805382988c75bc78f467cb387698175887dd2b98beb80aeaa9e6a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page