junchen1992 / py-snowflake

Generate Snowflake IDs and parse them back with Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

py-snowflake

Generate Snowflake IDs and parse them back with Python.

ℹ️ This is a Python implementation of Twitter's Snowflake algorithm.

Install

pip install py-snowflake-id

Sample Usage

from snowflake import SnowflakeGenerator

# Create Snowflake instance
sf_gen = SnowflakeGenerator(
    instance=0,  # Instance iD
)

# Get next ID generated by Snowflake algorithm
next_sf_id = next(sf_gen)

Snowflake Algorithm Explained

Here is a list of useful resources for understanding this algorithm:

About

Generate Snowflake IDs and parse them back with Python.

License:MIT License


Languages

Language:Python 100.0%