New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ulid-rs-py

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ulid-rs-py

Use rust ulid crate to rewrite python ulid library

  • 0.2.1
  • Source
  • PyPI
  • Socket score

Maintainers
1

ulid-rs-py

Package version Supported Python versions

Python wrapper for Rust ulid crate


Installation

pip install ulid-rs-py

Quickstart

from datetime import datetime, timezone
from ulid import new, from_uuid, from_parts, from_timestamp, from_datetime, from_string, PyUlid

# Generate ulid
py_ulid: PyUlid = new()
print(py_ulid)
print(py_ulid.str())
print(py_ulid.bytes())
print(py_ulid.increment())
print(py_ulid.randomness())
print(py_ulid.timestamp())

# From string
str_value = "01H6D6M1HWY1KNND0FKB8PRR87"
py_ulid = from_string(str_value)
print(py_ulid.str())
assert py_ulid.str() == str_value
assert py_ulid.randomness() + 1 == py_ulid.increment().randomness()

# From uuid
uuid_value = "771a3bce-02e9-4428-a68e-b1e7e82b7f9f"
ulid_value = "3Q38XWW0Q98GMAD3NHWZM2PZWZ"
py_ulid = from_uuid(uuid_value)
print(py_ulid.str())
assert py_ulid.str() == ulid_value

# From timestamp
timestamp_value = datetime(2023, 7, 28).timestamp()
py_ulid = from_timestamp(timestamp_value)
print(py_ulid.str())
print(py_ulid.timestamp())
assert py_ulid.timestamp() == timestamp_value
print(py_ulid.randomness())

# From datetime
datetime_value = datetime(2023, 7, 28, hour=1, minute=20, tzinfo=timezone.utc)
py_ulid = from_datetime(datetime_value)
assert py_ulid.str()
assert py_ulid.datetime() == datetime(2023, 7, 28, hour=1, minute=20)
assert py_ulid.timestamp() == datetime_value.timestamp()

# From parts
datetime_value = datetime(2023, 7, 28)
py_ulid_tt = from_timestamp(datetime_value.timestamp())
py_ulid = from_parts(py_ulid_tt.timestamp(), py_ulid_tt.randomness())
assert py_ulid.str() == py_ulid_tt.str()


Benchmarks

For details, see benchmark.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc