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.

Metadata

Release files for epyxid 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for epyxid 0.4.0
File Size Uploaded
epyxid-0.4.0.tar.gz 14.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for epyxid 0.4.0
File
epyxid-0.4.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
epyxid-0.4.0-cp310-abi3-win32.whl CPython 3.10 abi3 Windows x86-32 Details
epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl CPython 3.10 abi3 Linux glibc 2.17+ IBM System/390x Details
epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.10 abi3 Linux glibc 2.17+ PowerPC 64-le Details
epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.10 abi3 Linux glibc 2.17+ ARMv7l Details
epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.10 abi3 Linux glibc 2.5+ x86-32 Details
epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 2.4 MB

Release files / epyxid-0.4.0.tar.gz

Download URL epyxid-0.4.0.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0f0845aa83bca1a31990b4cf2cde9f89af2cfc094e8e583737ec29bf175664ba
BLAKE2b-256 checksum
How to use checksums
5c8bc98e73b991242bba3b2261d566a2a569a1548e49198c9110c33da5a5b022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-win_amd64.whl

Download URL epyxid-0.4.0-cp310-abi3-win_amd64.whl
Size 172.7 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b286d8570760d9c904b140e6ef82724679982ea19a58bdf557ef48dc7f05cf9a
BLAKE2b-256 checksum
How to use checksums
d6b36ba284e2699d0280cb253a2b415dacbf883e6de748da528d362d8cef1287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-win32.whl

Download URL epyxid-0.4.0-cp310-abi3-win32.whl
Size 164.1 kB
Tags CPython 3.10 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
748519a47ba031bb04b730f528458194c59c6e626ab3239650e9eca7c26003fe
BLAKE2b-256 checksum
How to use checksums
425b72975f3cb4afa114dbeaafbbaf06bce2e8086fd920761dd73361c26f67d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL epyxid-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 262.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c6d62217e8ed463129250a4fb1a537f306a64de3cba5c068dbf475458253f952
BLAKE2b-256 checksum
How to use checksums
06c6506df3a8c79b9d5198fe9c2d64a16a15be4546840ac75035eee00422d22e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL epyxid-0.4.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 288.8 kB
Tags CPython 3.10 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
955543e61e820ef3e0afea2d2147d6571e88dd010cf261e3dfa7ffac1fa9af7b
BLAKE2b-256 checksum
How to use checksums
7653c9cb5aa670586fdb3dd3276d6b4f884d8593363e4cb06b2da66697d257d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL epyxid-0.4.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 284.2 kB
Tags CPython 3.10 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
5e86487fcdb138556d5a427dfbd228f238843b0608874cc201f9ebef68f00863
BLAKE2b-256 checksum
How to use checksums
16de24d64c40e49318c49766a1794c7339c9bf88fa3d5cdf4951876c3062ed39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL epyxid-0.4.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 257.1 kB
Tags CPython 3.10 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
2384ecef86b240069e2ed129692ac23f8939b7b7cfb6ca9db4811c6d88542829
BLAKE2b-256 checksum
How to use checksums
9c8251bfe21fc1a5b658fc98108976b506118242ab0cfa4d4ea2e01ad2ea2359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL epyxid-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 252.7 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
674be3f8e61351483656acf567128790fb52c86aaf36c392bee7bc21dbec2cb3
BLAKE2b-256 checksum
How to use checksums
2a7fedda79ec3b04c0eb028d9915e3ef0ad884801058959e70f9a01b00c6a9ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl

Download URL epyxid-0.4.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Size 280.0 kB
Tags CPython 3.10 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
2d226dbf8ffd912b49897b9ffe0b7b2bc525b21dc5cbc8aabbeceabb02e5e88c
BLAKE2b-256 checksum
How to use checksums
88978e417beeadd669b9ea1af0cc97041a317b679de8d3ac946dd2cc5b206e75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL epyxid-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Size 223.3 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
49cf4d7765dcd35230a2aa2807ff52b0805dfbc5ebdca101afc824d5e04118ca
BLAKE2b-256 checksum
How to use checksums
8503bdb4c65bea277dab0e1f02ad04509d7c412986463dc35565396f965e6a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release files / epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL epyxid-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 248.6 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
fd7d4404dbd9dfa7e6aa73073ac602a14e465a0dcad9ccea6ab3c7d5f4af832b
BLAKE2b-256 checksum
How to use checksums
af5860d5458f6ca853a3aa2ad9151fdf8e43a95e0b5b9382323aaa66c1da5fb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.15.0

Release history Release notifications | RSS feed

This release

0.4.0 This release

11 release files

0.3.5

73 release files

0.3.4

73 release files

0.3.3

69 release files

0.3.2

63 release files

0.3.1

63 release files

0.3.0

67 release files

0.2.1

65 release files

0.2.0

65 release files

0.1.4

11 release 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