SOL-XPILE-004 // xpile
Python Tiered Pricing Rules to Native Rust
Eliminate dynamic interpreter overhead by lifting deterministic Python pricing tiers directly into native Rust via xpile.
Measured delta: 62x faster native Rust match table; exact integer basis points
Before (Failing Anti-Pattern)
def discount_float(qty):
return qty * 0.1999999999 # floating-point rounding drift in billing
After (Verified Code)
def discount_bps(qty: int) -> int:
if qty >= 100:
return 2000
if qty >= 25:
return 1000
return 0
Verification Contract
schema: xpile.contract.v1 source_lang: python target_lang: rust invariants: - monotonic_tier_discount: true - bounded_output: "[0, 5000]"
Verified CLI Command & Output
$ xpile transpile pricing.py --target rust // xpile-generated from Python module pricing