ePyXID
Fast, globally unique, and sortable ID generator.
ePyXID is a Python wrapper around the Rust implementation of xid: xid-rs. Built with PyO3, it provides a simple and efficient way to generate unique IDs that are sortable by creation time.
The original xid implementation is rs/xid written in Go.
Features
- Globally Unique: Each ID combines a timestamp, a machine identifier, a process identifier and a counter.
- Sortable: IDs sort by creation time with one-second granularity.
- Compact: 12 bytes, or 20 characters in its base32-hex form.
- Fast: Implemented in Rust for maximum performance using PyO3. See performance benchmarks comparing ePyXID with other Python ID generation libraries.
- Typed: Ships type stubs and
py.typed.
Installation
Requires Python 3.10 or newer.
pip install epyxid
Quick Start
from epyxid import XID, XIDError
# Generate a new ID
xid = XID()
print(repr(xid))
print(xid.time)
# Parse an existing ID from its string or binary form
from_str = XID('9m4e2mr0ui3e8a215n4g')
from_bytes = XID(b'\x4d\x88\xe1\x5b\x60\xf4\x86\xe4\x28\x41\x2d\xc9')
print(from_str == from_bytes)
# True
# Convert back
print(from_str.to_str())
# 9m4e2mr0ui3e8a215n4g
print(from_str.as_bytes())
# b'M\x88\xe1[`\xf4\x86\xe4(A-\xc9'
# Inspect the embedded fields
print(from_str.machine, from_str.pid, from_str.counter)
# b'`\xf4\x86' 58408 4271561
# IDs are ordered, hashable and picklable
print(XID() < XID())
# True
print(len({from_str, from_bytes}))
# 1
# Invalid input raises XIDError, a subclass of ValueError
try:
XID('not-an-xid')
except XIDError as error:
print(error)
# invalid XID string "not-an-xid": expected 20 characters, got 10
Only str and bytes are accepted; anything else raises TypeError.
Development
Requires a Rust toolchain, just and prek.
just venv # create .venv with maturin, pytest and mypy
just hooks # install git hooks
just tests # build the wheel and run the test suite
just stubs # type-check the stubs against the built module
just lint # cargo fmt and clippy
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 epyxid-0.4.0.tar.gz.
File metadata
- Download URL: epyxid-0.4.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f0845aa83bca1a31990b4cf2cde9f89af2cfc094e8e583737ec29bf175664ba
|
|
| MD5 |
147bab94420f685ea794486f0ac2b920
|
|
| BLAKE2b-256 |
5c8bc98e73b991242bba3b2261d566a2a569a1548e49198c9110c33da5a5b022
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 172.7 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b286d8570760d9c904b140e6ef82724679982ea19a58bdf557ef48dc7f05cf9a
|
|
| MD5 |
2a0b6bd679fe4a04dd7afbdb7886f38e
|
|
| BLAKE2b-256 |
d6b36ba284e2699d0280cb253a2b415dacbf883e6de748da528d362d8cef1287
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-win32.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-win32.whl
- Upload date:
- Size: 164.1 kB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
748519a47ba031bb04b730f528458194c59c6e626ab3239650e9eca7c26003fe
|
|
| MD5 |
6df97c5ff82a42b70906bf3d6c3432e7
|
|
| BLAKE2b-256 |
425b72975f3cb4afa114dbeaafbbaf06bce2e8086fd920761dd73361c26f67d2
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 262.6 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6d62217e8ed463129250a4fb1a537f306a64de3cba5c068dbf475458253f952
|
|
| MD5 |
33bb60231f052f69194df372e962f58f
|
|
| BLAKE2b-256 |
06c6506df3a8c79b9d5198fe9c2d64a16a15be4546840ac75035eee00422d22e
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 288.8 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
955543e61e820ef3e0afea2d2147d6571e88dd010cf261e3dfa7ffac1fa9af7b
|
|
| MD5 |
c35f11d39625aacbc6cb87edc1f1fd93
|
|
| BLAKE2b-256 |
7653c9cb5aa670586fdb3dd3276d6b4f884d8593363e4cb06b2da66697d257d8
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 284.2 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e86487fcdb138556d5a427dfbd228f238843b0608874cc201f9ebef68f00863
|
|
| MD5 |
8be759936b44b51113f69313f38c1877
|
|
| BLAKE2b-256 |
16de24d64c40e49318c49766a1794c7339c9bf88fa3d5cdf4951876c3062ed39
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 257.1 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2384ecef86b240069e2ed129692ac23f8939b7b7cfb6ca9db4811c6d88542829
|
|
| MD5 |
ff4b7c61c9c275d4b24d53e493647dad
|
|
| BLAKE2b-256 |
9c8251bfe21fc1a5b658fc98108976b506118242ab0cfa4d4ea2e01ad2ea2359
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 252.7 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
674be3f8e61351483656acf567128790fb52c86aaf36c392bee7bc21dbec2cb3
|
|
| MD5 |
e7a22fbdcedd10fa4a4a892062b31091
|
|
| BLAKE2b-256 |
2a7fedda79ec3b04c0eb028d9915e3ef0ad884801058959e70f9a01b00c6a9ed
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 280.0 kB
- Tags: CPython 3.10+, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d226dbf8ffd912b49897b9ffe0b7b2bc525b21dc5cbc8aabbeceabb02e5e88c
|
|
| MD5 |
715b9c3fbdea4ae887244c40095bb584
|
|
| BLAKE2b-256 |
88978e417beeadd669b9ea1af0cc97041a317b679de8d3ac946dd2cc5b206e75
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 223.3 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49cf4d7765dcd35230a2aa2807ff52b0805dfbc5ebdca101afc824d5e04118ca
|
|
| MD5 |
2d2893f5e89ba6d6d2dad9fae0120a09
|
|
| BLAKE2b-256 |
8503bdb4c65bea277dab0e1f02ad04509d7c412986463dc35565396f965e6a92
|
File details
Details for the file epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 248.6 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
maturin/1.15.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd7d4404dbd9dfa7e6aa73073ac602a14e465a0dcad9ccea6ab3c7d5f4af832b
|
|
| MD5 |
64cacede45db68897f6044e5ccd83249
|
|
| BLAKE2b-256 |
af5860d5458f6ca853a3aa2ad9151fdf8e43a95e0b5b9382323aaa66c1da5fb9
|