Skip to main content

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 128-bit sortable identifier with:

  • 16-byte canonical binary storage for databases and joins.
  • 22-character gid_s text for logs, URLs, and APIs.
  • 22-character gid_x public-token text for hiding timestamp and sort order.
  • Rust-native PyO3 backend for production use.

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/.

Release

Release a new version from packages/python after updating pyproject.toml to the next version. For example, to publish 0.0.3:

cd packages/python
uv version 0.0.3
uv sync --dev
uv run ruff check .
uv run ty check
uv run pytest
uv build
uvx twine check dist/*
uvx twine upload dist/*

If PyPI asks for credentials:

  • Username: __token__
  • Password: your PyPI API token

If you use Trusted Publishing instead of a token, keep the upload step but let PyPI verify the project identity through its configured publisher.

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

gid128-0.0.3.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gid128-0.0.3-cp314-cp314-macosx_11_0_arm64.whl (239.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

Details for the file gid128-0.0.3.tar.gz.

File metadata

  • Download URL: gid128-0.0.3.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for gid128-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c3c7b3363f7c2eaa1137c97f4e93107258da24f8ae41859574ca2e5260a6b771
MD5 f479e28e7347a7f0aa7d71a4eb07c7b5
BLAKE2b-256 2d466a495e60906c66c9fcbe56b0435d70718de0e5a510c3e85aadc349d4ce56

See more details on using hashes here.

File details

Details for the file gid128-0.0.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gid128-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46de941a4ef181dd25cd7269f11695794e6796e3ce8b8449121cafa71229fce5
MD5 cfed9871cdc9ffb838d35f8ce493daa7
BLAKE2b-256 8c3a26be7de0390b5481e3dabc290e396eca2067a1c6196b8332f119cb8b0df2

See more details on using hashes here.

Supported by

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