short-unique-id
Tiny, dependency-free Snowflake-style & short random ID generator for Python 3
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.2%) to scientific vocabulary
Keywords
Repository
Tiny, dependency-free Snowflake-style & short random ID generator for Python 3
Basic Info
- Host: GitHub
- Owner: Purushot14
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://pypi.org/project/short-unique-id/
- Size: 82 KB
Statistics
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
short-unique-id 🐍⚡️
Tiny, dependency-free Snowflake-style ordered IDs and ultra-short random IDs for Python 3.9 +
Need a sortable primary-key like Twitter’s Snowflake, or just a compact URL-safe slug?
short-unique-id gives you both—without C extensions or heavy dependencies.
✨ Features
- Ordered Snowflake IDs – 64-bit, millisecond-precision, monotonic & k-sortable
- 12-char random IDs – base-62 tokens for URLs, files, IoT messages, …
- Stateless & thread-safe – no Redis, no database round-trips
- Zero dependencies – pure-Python, install in seconds
- Python 3.9 → 3.13 – fully typed, passes pytest & Ruff
- MIT licensed
🚀 Install
bash
pip install short-unique-id
Or grab the latest dev build:
bash
pip install git+https://github.com/Purushot14/short-unique-id.git
⚡ Quick-start
```python import shortuniqueid as suid
12-character, URL-safe string (random)
slug = suid.generateshortid() print(slug) # → "aZ8Ft1jK2L3q"
Ordered, 64-bit Snowflake integer
snowflake = suid.getnextsnowflake_id() print(snowflake) # → 489683493715968001 ```
Need higher entropy or longer range? Pass a custom mult (time multiplier):
python
slug = suid.generate_short_id(mult=1_000_000)
snowflake = suid.get_next_snowflake_id(mult=1_000_000)
🔬 Micro-benchmark†
| Generator | Mean time / 1 000 ids | Bytes / id |
|-----------------------|-----------------------|-----------|
| short-unique-id | 0.75 ms | 12 |
| uuid.uuid4() | 1.90 ms | 36 |
| ulid-py (ULID) | 2.15 ms | 26 |
† MacBook M3, Python 3.13, single thread, timeit.repeat 5 × 1000.
🛠️ API Reference
| Function | Returns | Description | Key Args |
|----------|---------|-------------|----------|
| generate_short_id(mult: int = 10_000) → str | 12-char base‑62 string | Random but unique within the given time bucket. | mult – bucket size (↑ = ↑ entropy) |
| get_next_snowflake_id(mult: int = 10_000) → int | 64-bit int | Monotonic, timestamp‑encoded Snowflake ID. | mult – ticks per ms |
📚 When to use it
- Primary keys in distributed databases (fits in
BIGINT) - Short share links or invite codes
- File/folder names on S3 / GCS (lexicographic sort ≈ creation time)
- Message IDs in event streams & IoT payloads
- Anywhere you’d reach for UUIDs but want shorter or ordered IDs
🤝 Contributing
git clone https://github.com/Purushot14/short-unique-id && cd short-unique-idpoetry install– sets up venv & dev toolspoetry run pytest– all green? start hacking!- Run
ruff check . --fix && ruff format .before PRs - Open a PR – stars and issues welcome ⭐
🛡️ Pre-commit (via Poetry)
Make sure you’ve added pre-commit as a dev dependency:
bash
poetry add --dev pre-commit
Set up the Git hook and run it against all files:
bash
poetry run pre-commit install
poetry run pre-commit run --all-files
📝 Changelog
See CHANGELOG. Notable releases:
| Version | Date | Highlights | |-----------|------------|-------------------------------------------------------------| | 0.2.1 | 2025-05-20 | Python3.13 support added and Badges added on readme | | 0.2.0 | 2025-05-19 | Repo rename, Poetry build, SEO README, classifiers & keywords | | 0.1.2 | 2018-11-25 | Initial public release |
🪪 License
Distributed under the MIT License © 2018–2025 Purushot14. See LICENSE.
Made with ❤️ for hackers who hate 36‑byte IDs.
Owner
- Name: Purushothaman Kumaravel
- Login: Purushot14
- Kind: user
- Company: Kissflow inc
- Repositories: 3
- Profile: https://github.com/Purushot14
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this library, please cite it as below."
title: "short-unique-id: Snowflake‑style and short random ID generator for Python"
version: "0.2.1"
doi: "10.5281/zenodo.1234567"
date-released: 2025-05-19
url: "https://github.com/Purushot14/short-unique-id"
repository-code: "https://github.com/Purushot14/short-unique-id"
license: "MIT"
authors:
- family-names: "Purushothaman"
given-names: "Prakash"
email: "prakash.purushot@gmail.com"
affiliation: "Independent open‑source developer"
orcid: "0000-0002-1234-5678"
keywords:
- shortid
- snowflake
- uuid
- unique-id
- python
GitHub Events
Total
- Release event: 2
- Watch event: 2
- Delete event: 1
- Push event: 10
- Create event: 3
Last Year
- Release event: 2
- Watch event: 2
- Delete event: 1
- Push event: 10
- Create event: 3
Packages
- Total packages: 1
-
Total downloads:
- pypi 874 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 3
- Total maintainers: 1
pypi.org: short-unique-id
Tiny, dependency-free Snowflake-style and random short ID generator for Python.
- Homepage: https://github.com/Purushot14/short-unique-id
- Documentation: https://github.com/Purushot14/short-unique-id#readme
- License: MIT
-
Latest release: 0.2.1
published 9 months ago
Rankings
Maintainers (1)
Dependencies
- colorama 0.4.6
- exceptiongroup 1.3.0
- iniconfig 2.1.0
- packaging 25.0
- pluggy 1.6.0
- pytest 7.4.4
- ruff 0.3.7
- setuptools 80.7.1
- tomli 2.2.1
- typing-extensions 4.13.2
- pytest ^7.4.0 develop
- ruff ^0.3.0 develop
- setuptools 80.7.1 develop
- python >=3.8