Skip to main content

ToggleMesh Python SDK (Local Evaluation)

GitHub Repo

A lightweight, robust Python SDK for evaluating feature flags with ToggleMesh.

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")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

togglemesh-0.3.3.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

togglemesh-0.3.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file togglemesh-0.3.3.tar.gz.

File metadata

  • Download URL: togglemesh-0.3.3.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for togglemesh-0.3.3.tar.gz
Algorithm Hash digest
SHA256 e738e8de3fd0c82a6a463598523e68e7ad7586ab677a40a9ca5639fb1e205d30
MD5 9c6fb9bd89866535adfd0b9340c0612b
BLAKE2b-256 ccd4ceef7e0bb9004ae8fba49e2ba8017724428e561b0fc430a9265ce0219c59

See more details on using hashes here.

File details

Details for the file togglemesh-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: togglemesh-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for togglemesh-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e6b34bfbc8f2e12bc4248cf0094e1e54bf6994cce9f6dc86c6c8f11a8756cfd
MD5 38b7bfd18eec79bbc8a40c817d92dc57
BLAKE2b-256 7aba10981bb203082d185dcad0a20c587ff395a0366778f9be21994cbf9c7d38

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.4

2 files

This release

0.3.3 This release

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.9

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 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