Lesson 108: functools.partial and caches
Focus
Compare against yesterday's mental model politely: Intermediate drills functools.partial and caches; spin token 924518 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence8mixesfunctools.partial and caches; spin22206. - Ritual: Describe falsifying evidence that would veto this pattern.
- Own one invariant tied to
Intermediate.
Example (LESSON_UID = "intermediate-108")
# Intermediate drill L108 topic-10 micro-7 pattern-12
LESSON_UID = "intermediate-108"
spin_a, spin_b, spin_c = 957, 772, 897
from io import StringIO
buf = StringIO()
rounds = 3 + 7 % 5
for idx in range(rounds):
buf.write(f"seg-{idx}-{(idx * 108 + spin_b) % 997}\n")
buf.seek(0)
dump = buf.read()
print("lines", dump.count("\n"))
print("peek", dump.splitlines()[0] if dump else "<empty>")
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-108.txt"
snap = [121, 98, 75, 52, 29, 6]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (897 + 131))
Practice
Practice 34: Promote hottest literal into named constant; justify naming aloud. Literal nudge 34.
Fingerprints
- lesson_uid:
intermediate-108 - umbrella band:
functools.partial and caches(8/10) - lesson_index:
3474