Lesson 103: functools.partial and caches
Focus
Compare against yesterday's mental model politely: Intermediate drills functools.partial and caches; spin token 893583 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence3mixesfunctools.partial and caches; spin59963. - Ritual: Describe falsifying evidence that would veto this pattern.
- Guardrail: separate demo-trick from shipping discipline verbally.
Example (LESSON_UID = "intermediate-103")
# Intermediate drill L103 topic-10 micro-2 pattern-11
LESSON_UID = "intermediate-103"
spin_a, spin_b, spin_c = 732, 125, 565
bucket = dict(seed=2 + spin_a)
def tweak(offset):
local = bucket["seed"]
bucket["seed"] = local + offset
return bucket["seed"]
print(tweak(2), tweak(6), bucket)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-103.txt"
snap = [116, 854, 601, 348, 95]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (565 + 131))
Practice
Practice 3: Clone twice: expand literals vs shrink loops; compare narrative. Literal nudge 3.
Fingerprints
- lesson_uid:
intermediate-103 - umbrella band:
functools.partial and caches(3/10) - lesson_index:
3279