← Curriculum track ← Learn hub
Quanta GenAI Curriculum · Python · Intermediate

Python Intermediate — 144: Stress-test stdlib wedges with thread-safe queues centred on `datetime, naive vs UTC-aware instincts` [156212]

Lesson 144: datetime, naive vs UTC-aware instincts

Focus

Assume a reviewer executes this verbatim: Intermediate drills datetime, naive vs UTC-aware instincts; spin token 1188045 makes this page unlike its neighbours.

Key ideas

Example (LESSON_UID = "intermediate-144")

# Intermediate drill L144 topic-14 micro-3 pattern-11
LESSON_UID = "intermediate-144"
spin_a, spin_b, spin_c = 587, 719, 397

bucket = dict(seed=3 + spin_a)

def tweak(offset):
    local = bucket["seed"]
    bucket["seed"] = local + offset
    return bucket["seed"]

print(tweak(6), tweak(3), bucket)

from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as scratch:
    target = Path(scratch) / "scratch-144.txt"
    snap = [157, 751, 354, 948, 551, 154]
    target.write_text("\n".join(str(x) for x in snap), encoding="utf-8")
    print("scratch_bytes", target.stat().st_size, "rolling", sum(snap) % (397 + 131))

Practice

Practice 32: Promote hottest literal into named constant; justify naming aloud. Literal nudge 32.

Fingerprints