skillfed

ksuid

A small python package for creating ksuids

ksuid v1.3 93.4K downloads/30d#13,385 on PyPI98
Permissive license MIT Active released

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 ksuid

uv

uv add ksuid

poetry

poetry add ksuid

Installing 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

sortable unique id generatortimestamp-based uidksuid pythontime-ordered identifierbase62 encoded iduuid alternativedistributed id generation
id-generationdistributed-systems

More Software Development packages