ksuid
A small python package for creating ksuids
What it is and what it does
KSUID is a Python library for generating K-sorted unique identifiers—20-byte values combining a 4-byte timestamp with 16 bytes of random data. The timestamp component allows KSUIDs to be naturally sorted by creation time, addressing a key limitation of UUIDs. The library provides methods to extract the timestamp, convert to datetime objects, serialize to bytes, and encode/decode using Base62 for compact string representation.
The package has no runtime dependencies and is designed as a lightweight utility for applications needing distributed, time-ordered ID generation. It's particularly useful in systems where both uniqueness and temporal ordering matter, such as event logging, database record tracking, or distributed systems requiring causality-aware identifiers.
Use it for:
- Generate time-ordered event IDs in logging or audit systems where both uniqueness and chronological sorting are needed
- Create sortable primary keys for database records that reflect insertion order without explicit timestamp columns
- Assign unique identifiers in distributed systems where multiple nodes generate IDs independently without coordination
- Serialize IDs to compact Base62 strings for use in URLs or user-facing identifiers
- Replace UUID4 in applications where the 122-bit entropy of UUIDs is insufficient and time-ordering is valuable
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates sortable unique identifiers (KSUIDs) that combine a timestamp with random data, enabling time-ordered ID generation without external dependencies.
Yes, if you need sortable unique identifiers and can tolerate source-only installation. The package is stable, dependency-free, and solves a real problem (time-ordered IDs) that standard UUIDs don't address. However, verify Python 3.x compatibility with your target version before committing, and be aware that no release has shipped since 2017 despite active repository maintenance—this suggests the code is considered complete rather than actively developed.
Install
ksuid on PyPI
pip
pip install ksuiduv
uv add ksuidpoetry
poetry add ksuidInstalling ksuid
Before you install
High install friction due to source-only distribution (ksuid-1.3.tar.gz). Repository shows active maintenance with recent commits (2026-04-13), but the package has not received a release update since 2017-06-12, suggesting the codebase is stable but not actively developed.
License in practice
MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions beyond attribution.
Quickstart
pip install ksuid
from ksuid import ksuid
x = ksuid()
print(x)
print(x.getTimestamp())
print(x.toBase62())
Python 3.x required; currently only tested for Python 3.x per documentation.
Verify before relying
- Whether the package works reliably with modern Python versions (3.10+) given no release since 2017
- Performance characteristics under high-volume ID generation
- Collision probability claims relative to UUID4 in production scenarios
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 3,350 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 93,447/month — #13,385 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ksuid-1.3.tar.gz
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
cyksuidGenerates and parses KSUIDs (K-Sortable…
permissive · top 15,000 on PyPI
fractional-indexingGenerates sortable string keys for inserting…
permissive · top 15,000 on PyPI
pksuidGenerates prefixed, k-sortable unique…
permissive · top 15,000 on PyPI
svix-ksuidGenerates and parses KSUIDs (K-sorted unique…
permissive · top 15,000 on PyPI
timeflakeGenerates 128-bit, time-ordered, URL-safe…
permissive · top 15,000 on PyPI
uuid-extensionGenerates UUID version 7…
unclear · top 15,000 on PyPI
python-ulidGenerates and manipulates ULIDs (universally…
permissive · top 5,000 on PyPI
ulid-pyGenerates and parses ULIDs (Universally Unique…
permissive · top 5,000 on PyPI
ulidGenerates ULIDs (Universally Unique…
permissive · top 15,000 on PyPI
uuid7-standardGenerates and parses UUIDv7 identifiers with…
permissive · top 15,000 on PyPI