Simple snowflake id generator
Project description
Snowflake-tool
Snowflake tool is a Python library that implements the Snowflake algorithm and is used to generate Snowflake ID.
The default Twitter format shown below.
+------------------------------------------------------------------------------+
| 1 Bit Unused | 41 Bit Timestamp | 10 Bit Machine ID | 12 Bit Sequence ID |
+------------------------------------------------------------------------------+
Install
pip install snowflake-tool
Usage
from snowflake import Snowflake
gen = Snowflake(1)
for i in range(int(1e5)):
print(next(gen))
Of course, you could also generate one id by generator:
from snowflake import Snowflake
gen = Snowflake(1)
print(gen.generate())
Reference:
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-tool-1.0.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for snowflake_tool-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 080d970e7b6c6b64ed980051f1af5604c4d1f7a2ecdefbda46c09dbd64b798eb |
|
MD5 | bc761a9564341565e951ba46876d1895 |
|
BLAKE2b-256 | 3b2b60035632dcd28e80f537981b3fe4351a9256d92efe815cd49a730655b587 |