hanzo-flags
Feature flags + A/B testing for Python, on the Hanzo native flags engine.
The Python client for cloud /v1/flags — the same PostHog-compatible evaluation
endpoint the Rust core, Go binding, and @hanzo/flags (TypeScript) all speak. One
flag definition, evaluated identically in every language.
Zero runtime dependencies — stdlib urllib only. A flag check must never drag
a dependency tree into a service.
Install
pip install hanzo-flags # or: uv add hanzo-flags
Use
from hanzo_flags import HanzoFlags
flags = HanzoFlags("https://api.hanzo.ai", token="sk-...")
flags.load("user-123", person_properties={"plan": "pro"})
if flags.is_enabled("checkout-exp"):
...
variant = flags.variant("pricing-test") # "control" | "b" | None
payload = flags.payload("pricing-test") # the flag's JSON payload, or None
Group targeting (orgs/teams):
from hanzo_flags import Group
flags.load(
"user-123",
groups={"0": Group(key="acme", properties={"tier": "gold"})},
)
Async (asyncio services):
from hanzo_flags import AsyncHanzoFlags
flags = AsyncHanzoFlags("https://api.hanzo.ai", token="sk-...")
await flags.load("user-123")
if flags.is_enabled("checkout-exp"):
...
One-shot:
from hanzo_flags import evaluate
res = evaluate("https://api.hanzo.ai", "user-123", token="sk-...")
res.is_enabled("checkout-exp")
Guarantees
- Fail-open. A transport or decode error returns the last good (or empty)
result with
errors_while_computingset —load()never raises on the hot path. - Cached by context + TTL (default 15s). Re-evaluating the same context inside
the TTL is free, so a hot path may call
load()freely.
The family
| Language | Package | Mode |
|---|---|---|
| Rust | hanzo-flags crate |
native (the evaluation core) |
| Go | cloud/clients/flags |
in-process via FFI to the Rust core |
| TypeScript | @hanzo/flags |
HTTP to /v1/flags (browser + node) |
| Python | hanzo-flags |
HTTP to /v1/flags (this package) |
All four resolve the same flag to the same value: the definitions live once in the
cloud flags cockpit (/v1/flags/defs), and every client evaluates against them.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hanzo_flags-0.1.0.tar.gz.
File metadata
- Download URL: hanzo_flags-0.1.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2c67d54243434ab38ccca95e05fc8517078e4185715d5618c655d79fc2a4d92
|
|
| MD5 |
37111d48ddfb3f109ec0fff7d8b77a7f
|
|
| BLAKE2b-256 |
7e3f23f373230f9d7e7f23dce7863d7ff1ee9cbdd71b628fdb2c4e45547c7ecf
|
File details
Details for the file hanzo_flags-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hanzo_flags-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9cb4164910bae18d932ccdbbf81d2f1850df7e0562864c764fc4b4ad964a85d
|
|
| MD5 |
023504285bc37e617acd1503f06abc23
|
|
| BLAKE2b-256 |
f52b6b31deb0b5db4b3e651ae072c7fc634835db342f7c1bff7efcc581a1d9f1
|