This document explains how Rust acceleration works in the Python SDK, how to enable it, and what fallback behavior to expect.
The SDK can offload selected hot-path logic to Rust through optional Python bindings (drift-core-python), defined in the drift-core repository. This is controlled by environment flags and is designed to fail open.
At a high level:
- Python SDK logic remains the source of truth.
- Rust paths are opportunistic optimizations.
- If Rust is unavailable or fails at runtime, SDK behavior falls back to Python equivalents.
Rust is enabled by default when TUSK_USE_RUST_CORE is unset.
Use TUSK_USE_RUST_CORE to explicitly override behavior:
- Truthy:
1,true,yes,on - Falsy:
0,false,no,off
Examples:
# Explicitly enable (same as unset)
TUSK_USE_RUST_CORE=1
# Explicitly disable
TUSK_USE_RUST_CORE=0Rust acceleration requires the drift-core-python package to be installed in the runtime environment.
Notes:
- The SDK does not auto-install this package at runtime.
- If the package is missing or cannot be imported on a machine, the SDK continues on Python code paths.
You can install the SDK with Rust bindings via extras:
pip install "tusk-drift-python-sdk[rust]"drift-core publishes native artifacts across a defined support matrix. See:
If no compatible wheel exists for your environment, pip may attempt a source build of drift-core-python, which typically requires a Rust toolchain and native build prerequisites.
The bridge module is fail-open:
- Rust calls are guarded.
- On import failures or call exceptions, the corresponding helper returns
None. - Calling code then uses the existing Python implementation.
- On startup, the SDK logs whether Rust is enabled/disabled and whether it had to fall back to Python.
This means users do not need Rust installed to run the SDK when Rust acceleration is disabled or unavailable.
TUSK_SKIP_PROTO_VALIDATION=1This skips expensive protobuf validation checks in hot paths.
Use with care:
- Recommended only when parity/smoke tests are healthy.
- Keep it off in environments where strict serialization verification is preferred.
- Default production-safe posture: keep Rust enabled (default) only on tested deployment matrices.
- Performance posture: enable Rust + benchmark on your workloads before broad rollout.
- Reliability posture: keep parity tests and smoke tests in CI to detect drift between Python and Rust paths.