A Python generator for the Twitter Snowflake scheme
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
snowflake.py

README.md

A Python generator for the Twitter Snowflake scheme in 61 lines of spacious code.

    >>> import snowflake
    >>> s = snowflake.generator(1, 1)
    >>> s.next()
    1132805160360349696
    >>> s.next()
    1132805164143611904
    >>> s.next()
    1132805168782512128

    # convenience to convert a snowflake to a unix timestamp
    >>> snowflake.snowflake_to_timestamp(1132805168782512128)
    1413056012