Lesson 104: functools.partial and caches
Focus
Let the literals expose mistaken assumptions quickly: Intermediate drills functools.partial and caches; spin token 884866 makes this page unlike its neighbours.
Key ideas
- Angle
Intermediate: micro cadence4mixesfunctools.partial and caches; spin80733. - Ritual: Freeze one literal constant with a purposeful name aloud.
- Own one invariant tied to
Intermediate.
Example (LESSON_UID = "intermediate-104")
# Intermediate drill L104 topic-10 micro-3 pattern-1
LESSON_UID = "intermediate-104"
spin_a, spin_b, spin_c = 363, 976, 76
left, right = spin_a + 104, spin_b + 3
print(divmod(left + 3, max(3, (spin_c % 9) + 2)))
acc = (614 + 104) % (431 % 881 + 3 + 1)
for step in range(3 + (10 % 4)):
acc = acc * (spin_a % 11 + 3) % 100003
if acc % (spin_b % 8 + 2) == 0:
print("hit", step, acc)
print("trail", acc)
from pathlib import Path
import tempfile
with tempfile.TemporaryDirectory() as scratch:
target = Path(scratch) / "scratch-104.txt"
snap = [117, 487, 857, 236, 606, 976]
target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (76 + 131))
Practice
Practice 27: Enumerate three pytest markers you'd decorate if this lived in CI. Literal nudge 27.
Fingerprints
- lesson_uid:
intermediate-104 - umbrella band:
functools.partial and caches(4/10) - lesson_index:
3318