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.3.0.tar.gz
(4.9 kB
view hashes)
Built Distributions
sonyflake_py-1.3.0-py3.9.egg
(4.3 kB
view hashes)
Close
Hashes for sonyflake_py-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5433acfcd8177effa79511246a52f30b37ec773d9e2cec1a4733c57a45a18820 |
|
MD5 | c1c58cabb0e8629b84413e1d15a7ff7d |
|
BLAKE2b-256 | a98f2fa1e7c00a14f0b66bdd2403b7d902676a91f0ddc13e2e7f66ea55f725c3 |