4/37
Part 1 of 6 · Two limitsLearn and do
Three invariants and five edge cases are your test plan
Invariants are facts that must hold after every operation. Say them, then check them in your tests:
len(cache) <= capacity.- The map and the order hold exactly the same keys.
- The order is by last use, oldest first.
A cache stores None for a key, and get(key) returns None. Hit or miss?
Pick an answer above to see the rest
lru_cache(maxsize=0) wraps square, and square(3) runs twice. How many hits?
Pick one to see what it prints.
Pick an answer above to see the rest