Skip to main content

ulidx

English | 中文

ULID 的生成与转换:按时间可排序、可单调、线程安全。

安装

pip install ulidx

用法

from ulidx import Ulid

Ulid.generate()                       # '01M5K7Y6ZR56XPB757MMHC9ERD'
Ulid.generate(n_monotonic=True)       # 同毫秒内严格递增
Ulid.generate_batch(1000)

value = Ulid.generate()
Ulid.to_timestamp(value)              # epoch 秒
Ulid.to_time(value)                   # UTC+8 的 datetime
Ulid.by_bytes(Ulid.to_bytes(value))   # 往返
Ulid.from_uuid(Ulid.to_uuid(value))

说明

26 字符 Crockford base32,无连字符。n_monotonic=True 时单调状态按线程隔离,同一线程同一毫秒内生成的 ULID 严格递增,批量建 ID 也不会乱序。可双向转换 UUID、原始 16 字节与时间戳。

许可证

MIT


English

ULID generation and conversion: sortable, monotonic, thread-safe.

Install

pip install ulidx

Usage

from ulidx import Ulid

Ulid.generate()                       # '01M5K7Y6ZR56XPB757MMHC9ERD'
Ulid.generate(n_monotonic=True)       # 同毫秒内严格递增
Ulid.generate_batch(1000)

value = Ulid.generate()
Ulid.to_timestamp(value)              # epoch 秒
Ulid.to_time(value)                   # UTC+8 的 datetime
Ulid.by_bytes(Ulid.to_bytes(value))   # 往返
Ulid.from_uuid(Ulid.to_uuid(value))

Notes

26 Crockford base32 characters, no hyphens. With n_monotonic=True the generator state is per thread, so ULIDs created in the same millisecond strictly increase. Converts both ways to uuid.UUID, raw 16 bytes and timestamps.

License

MIT

Metadata

Release files for ulidx 0.0.3

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

Source distribution (sdist)

Source distribution for ulidx 0.0.3
File Size Uploaded Provenance
ulidx-0.0.3.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ulidx 0.0.3
File Interpreter ABI Platform
ulidx-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / ulidx-0.0.3.tar.gz

Download URL ulidx-0.0.3.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
705c574b05f4952579243007dcbcc594c294d2001abdac4960e53c37fca2a4a1
BLAKE2b-256 checksum
How to use checksums
8be6f3bba9cb274187b3c93e6bdb0aec28a143b839065b66a5716588f84895a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / ulidx-0.0.3-py3-none-any.whl

Download URL ulidx-0.0.3-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aad6a61ce2d1fafcd8313d93245b95704bf106cc8b125900e00e83b5042f22a9
BLAKE2b-256 checksum
How to use checksums
5b0c38ac775bbf3bc12e0e5c9d87d1cd459395c22654dd26b3abe2dec0bbd93e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for ulidx 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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