Skip to main content

ePyXID

PyPI version PyPI downloads

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

epyxid-0.4.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distributions

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

epyxid-0.4.0-cp310-abi3-win_amd64.whl (172.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

epyxid-0.4.0-cp310-abi3-win32.whl (164.1 kB view details)

Uploaded CPython 3.10+Windows x86

epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (262.6 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (288.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ s390x

epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (284.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ppc64le

epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (257.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (252.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl (280.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.5+ i686

epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl (223.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl (248.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

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

Hashes for epyxid-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0f0845aa83bca1a31990b4cf2cde9f89af2cfc094e8e583737ec29bf175664ba
MD5 147bab94420f685ea794486f0ac2b920
BLAKE2b-256 5c8bc98e73b991242bba3b2261d566a2a569a1548e49198c9110c33da5a5b022

See more details on using hashes here.

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

Hashes for epyxid-0.4.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b286d8570760d9c904b140e6ef82724679982ea19a58bdf557ef48dc7f05cf9a
MD5 2a0b6bd679fe4a04dd7afbdb7886f38e
BLAKE2b-256 d6b36ba284e2699d0280cb253a2b415dacbf883e6de748da528d362d8cef1287

See more details on using hashes here.

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

Hashes for epyxid-0.4.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 748519a47ba031bb04b730f528458194c59c6e626ab3239650e9eca7c26003fe
MD5 6df97c5ff82a42b70906bf3d6c3432e7
BLAKE2b-256 425b72975f3cb4afa114dbeaafbbaf06bce2e8086fd920761dd73361c26f67d2

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c6d62217e8ed463129250a4fb1a537f306a64de3cba5c068dbf475458253f952
MD5 33bb60231f052f69194df372e962f58f
BLAKE2b-256 06c6506df3a8c79b9d5198fe9c2d64a16a15be4546840ac75035eee00422d22e

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 955543e61e820ef3e0afea2d2147d6571e88dd010cf261e3dfa7ffac1fa9af7b
MD5 c35f11d39625aacbc6cb87edc1f1fd93
BLAKE2b-256 7653c9cb5aa670586fdb3dd3276d6b4f884d8593363e4cb06b2da66697d257d8

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 5e86487fcdb138556d5a427dfbd228f238843b0608874cc201f9ebef68f00863
MD5 8be759936b44b51113f69313f38c1877
BLAKE2b-256 16de24d64c40e49318c49766a1794c7339c9bf88fa3d5cdf4951876c3062ed39

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 2384ecef86b240069e2ed129692ac23f8939b7b7cfb6ca9db4811c6d88542829
MD5 ff4b7c61c9c275d4b24d53e493647dad
BLAKE2b-256 9c8251bfe21fc1a5b658fc98108976b506118242ab0cfa4d4ea2e01ad2ea2359

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 674be3f8e61351483656acf567128790fb52c86aaf36c392bee7bc21dbec2cb3
MD5 e7a22fbdcedd10fa4a4a892062b31091
BLAKE2b-256 2a7fedda79ec3b04c0eb028d9915e3ef0ad884801058959e70f9a01b00c6a9ed

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 2d226dbf8ffd912b49897b9ffe0b7b2bc525b21dc5cbc8aabbeceabb02e5e88c
MD5 715b9c3fbdea4ae887244c40095bb584
BLAKE2b-256 88978e417beeadd669b9ea1af0cc97041a317b679de8d3ac946dd2cc5b206e75

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49cf4d7765dcd35230a2aa2807ff52b0805dfbc5ebdca101afc824d5e04118ca
MD5 2d2893f5e89ba6d6d2dad9fae0120a09
BLAKE2b-256 8503bdb4c65bea277dab0e1f02ad04509d7c412986463dc35565396f965e6a92

See more details on using hashes here.

File details

Details for the file epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fd7d4404dbd9dfa7e6aa73073ac602a14e465a0dcad9ccea6ab3c7d5f4af832b
MD5 64cacede45db68897f6044e5ccd83249
BLAKE2b-256 af5860d5458f6ca853a3aa2ad9151fdf8e43a95e0b5b9382323aaa66c1da5fb9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

11 files

0.3.5

73 files

0.3.4

73 files

0.3.3

69 files

0.3.2

63 files

0.3.1

63 files

0.3.0

67 files

0.2.1

65 files

0.2.0

65 files

0.1.4

11 files

0.1.3

65 files

0.1.2

23 files

0.1.1

23 files

0.1.0

25 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page