Lesson 101: functools.partial and caches
Focus
Assume a reviewer executes this verbatim: Intermediate drills functools.partial and caches; spin token 852859 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence1mixesfunctools.partial and caches; spin77189. - Ritual: Mirror the snippet with reversed iteration order verbally.
- Guardrail: pick the budget that keeps this rehearsal honest.
Example (LESSON_UID = "intermediate-101")
# Intermediate drill L101 topic-10 micro-0 pattern-11
LESSON_UID = "intermediate-101"
spin_a, spin_b, spin_c = 654, 445, 133
bucket = dict(seed=0 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(2), tweak(4), bucket)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-101.txt"
snap = [114, 772, 439]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (133 + 131))
Practice
Practice 30: Attach property-style expectations referencing tuple shapes. Literal nudge 30.
Fingerprints
- lesson_uid:
intermediate-101 - umbrella band:
functools.partial and caches(1/10) - lesson_index:
3201