Skip to main content

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.g()))

Of course, you could also generate one id by generator:

from snowflake import Snowflake

gen = Snowflake(1)
print(gen.gen_id())

Reference:

  1. twitter-archive/snowflake: Snowflake is a network service for generating unique ID numbers at high scale with some simple guarantees. (github.com)
  2. bwmarrin/snowflake: A simple to use Go (golang) package to generate or parse Twitter snowflake IDs (github.com)
  3. Snowflake ID - Wikipedia

Metadata

Release files for snowflake-tool 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowflake-tool 2.0.3
File Size Uploaded
snowflake_tool-2.0.3.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snowflake-tool 2.0.3
File Interpreter ABI Platform
snowflake_tool-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / snowflake_tool-2.0.3.tar.gz

Download URL snowflake_tool-2.0.3.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4d8a98435206124c2700ca3f3d0de7186e662b6baa0b3d96fb0d41539bb6c7c6
BLAKE2b-256 checksum
How to use checksums
063f8d08581e89fa374867b0d2facc458bd8d814a87cb2f9dc542400803c7c94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / snowflake_tool-2.0.3-py3-none-any.whl

Download URL snowflake_tool-2.0.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cbec3ca191c199739c7c7b6034639ab378baa2816619592549b233bce0e8ef5
BLAKE2b-256 checksum
How to use checksums
f3357869978e17f1624cb9a053148cb6404612cc48e4531c2db2aba99c06b516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page