Skip to main content

SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier

Project description

SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier

PyPI License

SCRU64 ID offers compact, time-ordered unique identifiers generated by distributed nodes. SCRU64 has the following features:

  • 63-bit non-negative integer storable as signed/unsigned 64-bit integer
  • Sortable by generation time (as integer and as text)
  • 12-digit case-insensitive textual representation (Base36)
  • ~38-bit Unix epoch-based timestamp that ensures useful life until year 4261
  • Variable-length node/machine ID and counter fields that share 24 bits
# pass node ID through environment variable
import os

os.environ["SCRU64_NODE_SPEC"] = "42/8"

import scru64

# generate a new identifier object
x = scru64.new_sync()
print(x)  # e.g., "0u2r85hm2pt3"
print(int(x))  # as a 64-bit unsigned integer


# generate a textual representation directly
print(scru64.new_string_sync())  # e.g., "0u2r85hm2pt4"

See SCRU64 Specification for details.

SCRU64's uniqueness is realm-specific, i.e., dependent on the centralized assignment of node ID to each generator. If you need decentralized, globally unique time-ordered identifiers, consider SCRU128.

License

Licensed under the Apache License, Version 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scru64-1.0.2.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scru64-1.0.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file scru64-1.0.2.tar.gz.

File metadata

  • Download URL: scru64-1.0.2.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.2.0

File hashes

Hashes for scru64-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9b5ff1d2b732c465f081778095ffe9a4f536ba7373ea8ae18f1583450bf5648d
MD5 6cbd29c1ed5f86129294c45a19234bd1
BLAKE2b-256 5ee9da8cf5347b6256974f454f365d04f099d89e80184a479fb8122cc12e4e4b

See more details on using hashes here.

File details

Details for the file scru64-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: scru64-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.2.0

File hashes

Hashes for scru64-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d8fb7dbecd1e461a42af561ea28b50037b4a4f25b6470c3c2d5487751a1359c
MD5 334da53da28129d8487ed1f8221a6801
BLAKE2b-256 60b272b885c1cc3b1740a0410b97def2538e15dc1788b92f91952df1c2d70b95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page