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
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
snowflake.py-1.0.0.tar.gz
(2.9 kB
view hashes)
Built Distributions
snowflake.py-1.0.0-py3.8.egg
(3.1 kB
view hashes)
Close
Hashes for snowflake.py-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2777de34b19e7e8ef6e52071dc7d3faeb1df9a72c24635dfcd50ec01912a2dbc |
|
MD5 | 6e70861a341cb8b250b34f921c3d560b |
|
BLAKE2b-256 | 52138b4b057b4453b5c000d52336748911a52c8ce1dc00ab66ca11877a05f449 |