A distributed unique ID generator inspired by Twitter's Snowflake.
Project description
sonyflake-py
Sonyflake is a distributed unique ID generator inspired by Twitter's Snowflake.
This is a python rewrite of the original sony/sonyflake project, written in Go.
A Sonyflake ID is composed of
39 bits for time in units of 10 msec
8 bits for a sequence number
16 bits for a machine id
Installation
pip install sonyflake-py
Quickstart
from sonyflake import SonyFlake
sf = SonyFlake()
next_id = sf.next_id()
print(next_id)
The generator can be configured with variety of options, such as
custom machine_id
, start_time
etc.
start_time
should be an instance ofdatetime.datetime
.machine_id
should be a callable which returns an integer value upto 16-bits.
License
The MIT License (MIT).
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
sonyflake-py-1.2.0.tar.gz
(4.1 kB
view hashes)
Built Distributions
sonyflake_py-1.2.0-py3.9.egg
(4.1 kB
view hashes)
Close
Hashes for sonyflake_py-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efa71c419b31e12fe377e5761507c0eabb4f0e33c49fc6d00e2df0f944cd4cb |
|
MD5 | 016741e7c2d59b0656d7450dad287e18 |
|
BLAKE2b-256 | f086a04d6f4a50d62158f7dbe6838b27663357d6ae7cedb9ce93d267ef2ef88f |