GID-128 sortable 128-bit identifiers with 22-character text and opaque public tokens.
Project description
gid128
gid128 is the Python package for GID-128, a fast 128-bit sortable identifier for backend systems, databases, and APIs.
It gives you:
- 16-byte canonical binary storage for databases and joins.
- 22-character
gid_stext for logs, URLs, and APIs. - 22-character
gid_xpublic-token text for hiding timestamp and sort order. - Rust-native PyO3 backend for production use.
Why teams use it:
- Fast generation through the Rust-backed Python extension.
- Python benchmark results on Apple M4 / darwin arm64:
| Library | Ops/sec | GID speed |
|---|---|---|
gid128/generate |
1.2M | 1.000x |
ulid-py |
1.0M | 1.181x slower |
ksuid |
907K | 1.345x slower |
uuid/v4 |
896K | 1.360x slower |
uuid/v7 |
772K | 1.579x slower |
nanoid |
513K | 2.378x slower |
- Benchmarks compare against UUID v4, UUID v7, ULID, NanoID, KSUID, and other common ID generators where available.
- The benchmark gate is release-blocking and records the measured winners in the repo.
- Stable binary identity for indexing and joins.
- Public tokens that keep internal ordering out of user-facing URLs.
- Shared conformance vectors with the JS package.
Install:
uv add gid128
Basic usage:
from gid128 import gid, public_encode, public_decode
id = gid()
text = str(id)
key = bytes([1]) * 32
public_id = public_encode(id, key)
same = public_decode(public_id, key)
assert same == id
Included API surface:
- Canonical IDs:
gid,parse,from_bytes,from_hex,Gid128. - Public URL IDs:
public_encode,public_decode, keyed public tokens. - UUID-style compatibility helpers:
v1,v3,v4,v5,v6,v7,validate,nil,max. - ULID-style helpers:
encode_time,decode_time,monotonic_factory,factory. - NanoID-style helpers:
custom_alphabet,custom_random,non_secure. - Type-prefixed IDs:
with_prefix,parse_prefixed,get_type,get_suffix. - DB helpers:
to_buffer,from_buffer,to_sql_hex,from_sql_hex,sql_hex_to_bytes.
Local validation:
uv sync --dev
uv run ruff format .
uv run ruff check .
uv run ty check
uv run pytest --cov=gid128 --cov-report=term-missing --cov-fail-under=95
uv build
uv run python examples/basic.py
Repo-level validation:
npm run python:validate
Benchmark:
npm run bench:python
The repo-level npm run bench runs all implemented language benchmarks and writes JSON results
under bench-results/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gid128-0.0.4.tar.gz.
File metadata
- Download URL: gid128-0.0.4.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9ffbbaf779f1922e29ecc6ed81e49860ab8cb57475f0c584b867e2ec01bbe1d
|
|
| MD5 |
b7fc0b9049facfa4029b47fdc7cf24a1
|
|
| BLAKE2b-256 |
b8d0c15bfd27f2716a6fcec6e834c9855c9cd8fbc8b248c24ddbd03a33985e2a
|
File details
Details for the file gid128-0.0.4-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: gid128-0.0.4-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 239.1 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a86c49eb3734b8871d288303763a15e4c1fe7118763a8425110b0769e925273
|
|
| MD5 |
77abdd8e6956e323e6575a89cb2654cf
|
|
| BLAKE2b-256 |
2c699d241c8c8e0c34fb0ec21d2bb47b8f3c20ce483e3545c537e008e93834b3
|