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.2

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.2
File Size Uploaded Provenance
ulidx-0.0.2.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 14.6 kB

Release files / ulidx-0.0.2.tar.gz

Download URL ulidx-0.0.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
290a289cc72865e815f6676c8023a1d745ac44041d1a6ab9d50635b9ff7856ab
BLAKE2b-256 checksum
How to use checksums
a1adfa5e56548cdedb31f752c1fde41f696ba2cb5d3281f9229fefda81b2ac1d
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.2-py3-none-any.whl

Download URL ulidx-0.0.2-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d042eafd434d59831477daa10cb99595d91012497bde87a4c497124525da5a71
BLAKE2b-256 checksum
How to use checksums
9347af4f560c1b86bfe78367f5e562501e0f82c338de5239a2f9c9ba523327e8
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.2

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