Create and transform ULIDs
Project description
Fast ULID transformations
Create and transform ULIDs
This library will use the CPP implementation from https://github.com/suyash/ulid if cython is available, and will fallback to pure python if it is not.
Example
>>> import ulid_transform
>>> ulid_transform.ulid_hex()
'01869a2ea5fb0b43aa056293e47c0a35'
>>> ulid_transform.ulid_now()
'0001HZX0NW00GW0X476W5TVBFE'
>>> ulid_transform.ulid_at_time(1234)
'000000016JC62D620DGYNG2R8H'
>>> ulid_transform.ulid_to_bytes('0001HZX0NW00GW0X476W5TVBFE')
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
>> ulid_transform.bytes_to_ulid(b"\x01\x86\x99?\xe8\xf3\x11\xbc\xed\xef\x86U.9\x03z")
'01GTCKZT7K26YEVVW6AMQ3J0VT'
>>> ulid_transform.ulid_to_bytes_or_none('0001HZX0NW00GW0X476W5TVBFE')
b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee'
>>> ulid_transform.ulid_to_bytes_or_none(None)
>>> ulid_transform.bytes_to_ulid_or_none(b'\x00\x00c\xfe\x82\xbc\x00!\xc0t\x877\x0b\xad\xad\xee')
'0001HZX0NW00GW0X476W5TVBFE'
>>> ulid_transform.bytes_to_ulid_or_none(None)
Installation
Install this via pip (or your favourite package manager):
pip install ulid-transform
Contributors ✨
Thanks to https://github.com/suyash/ulid which provides the cython implementation guts.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
This package was created with Copier and the browniebroke/pypackage-template project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ulid_transform-0.11.0.tar.gz
(14.9 kB
view hashes)
Built Distribution
Close
Hashes for ulid_transform-0.11.0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e30d5a989de31551827c2514ba59992b71a9dbc2f0e352d0c52765e6754e8ca1 |
|
MD5 | 0152616c75e9e0b33b16a655e81c5888 |
|
BLAKE2b-256 | 7ff3b1da13b512aebb0c2e3511e8841a869e875240580b29ad94b1b3999c5d29 |