Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊSenior Deep-DivesModule 2 Β· CPython performance Β· Recapβ€ΊπŸŽ― Review: Senior Python module 2 recapscenario43 / 105
+80 XP
Task
Build a small `lru_estimator(cache_size, total_keys, hot_ratio)` returning estimated hit ratio (float, 4 decimal places): Model: - Hot keys = `int(total_keys * hot_ratio)` β€” fit entirely in cache if `hot_keys <= cache_size`. - If `hot_keys <= cache_size`: hit ratio β‰ˆ `hot_ratio` (every hot access hits, cold misses). - If `hot_keys > cache_size`: cache thrashes; effective hit ratio β‰ˆ `(cache_size / hot_keys) * hot_ratio`. Return value rounded to 4 decimals via `round(x, 4)`.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…