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 details)
Built Distribution
File details
Details for the file snowflake-tool-1.0.0.tar.gz
.
File metadata
- Download URL: snowflake-tool-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c5a680e4baf82bd2e1bbc50e27d5304a58508b2ca5d0a201e6ceae8bc7b55ab0
|
|
MD5 |
0756ec0e8eccbccebe4a4826b026c84a
|
|
BLAKE2b-256 |
f3faeb53bbdb918c384a89c9ef17bc414103430ad130bad06c2c47131f33089c
|
File details
Details for the file snowflake_tool-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: snowflake_tool-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
080d970e7b6c6b64ed980051f1af5604c4d1f7a2ecdefbda46c09dbd64b798eb
|
|
MD5 |
bc761a9564341565e951ba46876d1895
|
|
BLAKE2b-256 |
3b2b60035632dcd28e80f537981b3fe4351a9256d92efe815cd49a730655b587
|