Skip to main content

Simple Twitter snowflake-like id generator

Project description

snowflake.py

This is just a simple library for creating and managing twitter-like snowflake identifiers.

How do I use it?

Its honestly really simple to generate a snowflake.

import snowflake
import time

# The generator takes 3 arguments,
# The epoch timestamp, The number of seconds since the Unix Epoch
#   That we want to base all of our snowflake timestamps from.
#   By default it does time.time()/1000 and uses that.
# The process_id, By default it is the PID of the process however this can be
#   Whatever identifer you would like
# The worker_id, By default its 0, However it can also be whatever number you decide.
generator = snowflake.Generator()

# Then we just call generate and optionally provide a timestamp
snowflake = generator.generate()

Once you generate the snowflake, you can get an int using int() or string using str(), It has some properties added to it, they are timestamp, process_id, and worker_id and they give as they say.

Its pretty simple. :)

if you have any issues or questions feel free to post an issue.

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

snowflake.py-1.0.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distributions

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

snowflake.py-1.0.0-py3.8.egg (3.1 kB view details)

Uploaded Egg

snowflake.py-1.0.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file snowflake.py-1.0.0.tar.gz.

File metadata

  • Download URL: snowflake.py-1.0.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for snowflake.py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0aadd4ed6eae404796a6a581ee21f86dcb649ba3b2d867e573398e8b4e4f221b
MD5 610c0b59ff904aba91801bc722381f57
BLAKE2b-256 95f260471b921473c9381c13cf0ace4b79808673786c4fd467fd87dceeae519a

See more details on using hashes here.

File details

Details for the file snowflake.py-1.0.0-py3.8.egg.

File metadata

  • Download URL: snowflake.py-1.0.0-py3.8.egg
  • Upload date:
  • Size: 3.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for snowflake.py-1.0.0-py3.8.egg
Algorithm Hash digest
SHA256 0ab81bce2a8e035a535220cb4bc776db01d5a2b4248646b22a578710247b984a
MD5 cde6dbdfc70b3ce187d4bbd12e2cb1b5
BLAKE2b-256 b8dfe2581d75443daaee7a17e5ccb9785ff569b2867a536dd2dead0530a3313a

See more details on using hashes here.

File details

Details for the file snowflake.py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: snowflake.py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for snowflake.py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2777de34b19e7e8ef6e52071dc7d3faeb1df9a72c24635dfcd50ec01912a2dbc
MD5 6e70861a341cb8b250b34f921c3d560b
BLAKE2b-256 52138b4b057b4453b5c000d52336748911a52c8ce1dc00ab66ca11877a05f449

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