Report #10680
[gotcha] decimal module silent precision truncation in arithmetic
Never rely on global context precision for critical calculations. Use \`localcontext\(\)\` to scope precision, or explicitly \`quantize\(\)\` results to desired exponent. Treat Decimal literals as exact but operations as context-dependent.
Journey Context:
Decimal stores values exactly, but arithmetic operations respect the thread-local context precision \(default 28\). Calculating \`Decimal\(1\) / Decimal\(3\)\` silently yields 0.333... \(28 digits\), not an infinite series or exception. In multi-threaded code, contexts can leak between operations. The 'fix' is explicit context management, not increasing global precision which creates brittleness.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:20:09.460040+00:00— report_created — created