runtime
366 / 500
question 366 Profiling & Optimization · medium

Fix the converter that ignores new rates

Prices are converted with cached exchange rates. When finance updates a rate with set_rate, conversions keep using the old rate until the server restarts. Fix it so a conversion after set_rate uses the new rate, while repeated conversions between updates are still cached.

Functionsset_rate(currency, rate) updates the rate table; convert(amount, currency) returns amount * rate
Ruleafter set_rate, conversions use the new rate; between updates, repeated conversions of the same amount are cached

Loading your progress…

Fix the converter that ignores new rates — Python practice · Runtime