Skip to main content

chatora.mmid

Python helper libraries for MMID which is similar to UUIDv1 but sortable.

Usage

import datetime
import random
import uuid
from chatora.mmid.api import BaseMMID1


BASE_DT = datetime.datetime(2011, 1, 1, tzinfo=datetime.timezone.utc)


class MMID1v0(BaseMMID1):
    __slots__ = ('int',)
    UUID_VERSION = 4
    MMID_VERSION = 0
    TS_BIT_LENGTH = 55
    EPOCH_DT = datetime.datetime(2010, 1, 1, tzinfo=datetime.timezone.utc)


# Construct
assert MMID1v0().version == 4
assert MMID1v0(dt=BASE_DT).dt == MMID1v0(ts=BASE_DT.timestamp()).dt == BASE_DT


# Sortable, which is useful for RDB column index (PostgreSQL UUID/BYTEA, MySQL BINARY).
assert MMID1v0(dt=BASE_DT) < MMID1v0(dt=BASE_DT + datetime.timedelta(days=1))

clock_seq = random.getrandbits(14)
assert MMID1v0(dt=BASE_DT, clock_seq=clock_seq) == MMID1v0(dt=BASE_DT, clock_seq=clock_seq)

# create_min_instance_from_time()/create_max_instance_from_time() may be useful in case of range query on RDB.
assert MMID1v0.create_min_instance_from_time(
    dt=BASE_DT,
) == MMID1v0(hex_='811ed178-c6c0-4000-0000-000000000000')

assert MMID1v0.create_max_instance_from_time(
    dt=BASE_DT,
) == MMID1v0(hex_='811ed178-c6c0-4000-ffff-ffffffffffff')



# Compatible with UUID1
uuid1 = uuid.uuid1()
mmid1v0 = MMID1v0(src_uuid1=uuid1)

assert uuid1 == mmid1v0
assert mmid1v0.uuid1 == uuid1

Changelog

0.1 (2019-01-16)

  • Birth!

0.1.1 (2019-01-16)

  • Remove unused requirements.

0.1.2 (2019-01-17)

  • Fix timestamp/datetime precision.
  • Accept decimal.Decimal() timestamp values.

0.1.3 (2019-01-17)

  • Fix timestamp/datetime precision.

0.1.4 (2019-05-14)

  • Remove structlog dependency.

Metadata

Release files for chatora.mmid 0.1.4

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

Source distribution (sdist)

Source distribution for chatora.mmid 0.1.4
File Size Uploaded Provenance Actions
chatora.mmid-0.1.4.tar.gz 10.1 kB Without provenance Details for chatora.mmid-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chatora.mmid 0.1.4
File Interpreter ABI Platform Actions
chatora.mmid-0.1.4-py37-none-any.whl Python 3.7 none any Details for chatora.mmid-0.1.4-py37-none-any.whl

Total release size: 20.2 kB

Release files / chatora.mmid-0.1.4.tar.gz

Download URL chatora.mmid-0.1.4.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
294c100c06cc66bdc30c51904bf6752b716fe61dca53fe1753bdfb433deac9da
BLAKE2b-256 checksum
How to use checksums
9627544b9025815edcdb89c7a4580553c3965ed6b40b5fddfbd36b2841461262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

Release files / chatora.mmid-0.1.4-py37-none-any.whl

Download URL chatora.mmid-0.1.4-py37-none-any.whl
Size 10.1 kB
Tags Python 3.7
SHA-256 checksum
How to use checksums
15446df28732d6159486d724587713394c48d6e95f5b8fe2535b3f291bf8f847
BLAKE2b-256 checksum
How to use checksums
2c0518f00cc8a4aa798d6ab202b94dd8795c00602049dde8205625f802f33aa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

Security for chatora.mmid 0.1.4

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