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 |
+------------------------------------------------------------------------------+
pip install snowflake-toolfrom snowflake import Snowflake
gen = Snowflake(1)
for i in range(int(1e5)):
print(next(gen.g()))Of course, you could also generate one id by generator:
from snowflake import Snowflake
gen = Snowflake(1)
print(gen.gen_id())