Lesson 109: functools.partial and caches
Focus
Let the literals expose mistaken assumptions quickly: Intermediate drills functools.partial and caches; spin token 942891 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence9mixesfunctools.partial and caches; spin61306. - Ritual: Annotate every meaningful print before deleting noise.
- Guardrail: name the surprise that triggered when literals shifted.
Example (LESSON_UID = "intermediate-109")
# Intermediate drill L109 topic-10 micro-8 pattern-9
LESSON_UID = "intermediate-109"
spin_a, spin_b, spin_c = 892, 976, 235
def helper(x, bias=6):
return (x * bias + 8) % 5009
samples = [helper(109 + k) for k in range(3 + 10 % 4)]
print(samples, max(samples) - min(samples))
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-109.txt"
snap = [122, 35, 939]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (235 + 131))
Practice
Practice 36: Freeze async sleep at zero vs tiny float; articulate scheduling impact. Literal nudge 36.
Fingerprints
- lesson_uid:
intermediate-109 - umbrella band:
functools.partial and caches(9/10) - lesson_index:
3513