ToggleMesh Python SDK (Local Evaluation)
A lightweight, robust Python SDK for evaluating feature flags with ToggleMesh.
📖 Read the full documentation here: docs.togglemesh.dev
This SDK uses Local Evaluation. It connects to the ToggleMesh control plane once to fetch all rules, establishes an SSE (Server-Sent Events) connection to listen for updates, and evaluates all flags locally in-memory without making network requests. This ensures ultra-fast responses (sub-millisecond) suitable for high-throughput backend services.
Installation
pip install togglemesh
Usage
import time
from togglemesh import ToggleMeshClient, ToggleMeshOptions
client = ToggleMeshClient(ToggleMeshOptions(
base_url="http://localhost:5000",
server_key="YOUR_API_KEY"
))
# 1. Check a flag locally (Zero network latency!)
# Pass identity and context per-evaluation, since the server handles multiple users concurrently.
if client.is_enabled("new-feature", default_value=False, identity="user-123", tenant="sample_corp"):
print("Feature is ON")
else:
print("Feature is OFF")
# 2. Stop background threads when the app shuts down
client.stop()
Supported Features
- Percentage Rollouts (Murmur3 / FNV-1a hashing)
- Operator matching (Strings, Numbers, Dates, SemVer, Regex)
- Real-time SSE updates
- Contextual Rollouts
- Segment Evaluation
- JSON Parsing
client.get_json(...) - Analytics Event Tracking (A/B testing conversions):
client.track("checkout_completed", value=150.0, identity="user-123", cart_size=3)
🚀 CLI Tool (Code Generation)
The togglemesh Python package also includes a powerful Command Line Interface for synchronizing feature flags from the control plane and generating strongly-typed Python classes. This eliminates typos and gives you full IDE autocomplete for your flag keys!
1. Setup Configuration
Run the configuration wizard to link the CLI to your ToggleMesh environment.
togglemesh config
2. Generate Typed Flags
Synchronize your flags and output a native Python file containing your flag constants:
togglemesh sync -l python -o ./flags.py
Now you can use the generated Flags class in your code:
from flags import Flags
from togglemesh import ToggleMeshClient, ToggleMeshOptions
# ...
client.is_enabled(Flags.NEW_CHECKOUT_FLOW, default_value=False, identity="user-123")
Metadata
Release files for togglemesh 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| togglemesh-0.3.4.tar.gz | 13.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| togglemesh-0.3.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.5 kB
Release files / togglemesh-0.3.4.tar.gz
| Download URL | togglemesh-0.3.4.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a9c091c1458b74a227f7b07491e6fbeed2df95feacee44384642b463b43fc6b
|
|
BLAKE2b-256 checksum How to use checksums |
74e46ba17dca0eda3de6d65fa54b6bff760045558e37328a945e73b37da4aa79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / togglemesh-0.3.4-py3-none-any.whl
| Download URL | togglemesh-0.3.4-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a062ce8e702df4a9d70b617d9f9b5da79c5dee7f24c28c06cadfc248cd30ed41
|
|
BLAKE2b-256 checksum How to use checksums |
2e168e17581b30a9c3b74a15262ac14885bb3289e3cec918387f5565f46d5738
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for togglemesh 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.