LESSON 0.2 · Code · 90 min
Python objects, iterators, and vectorized thinking
Python objects, iterators, and vectorized thinking. Learn reference semantics, broadcasting, slicing, generators, and complexity and complete: Count bigrams in batches without Pyth
Learning objectives
- Explain what problem “Python objects, iterators, and vectorized thinking” solves without hiding behind terminology.
- Trace the variables and causal links across reference semantics, broadcasting, slicing.
- Complete “Count bigrams in batches without Python loops” and judge the result with evidence rather than intuition.
Core concepts
reference semantics
reference semantics is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment before moving to an optimized implementation.
broadcasting
broadcasting is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.
slicing
slicing is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.
generators
generators is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.
and complexity
and complexity is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.
Build and verify
Count bigrams in batches without Python loops
- Predict: write the expected output, trend, or failure before running code.
- Build: implement only the minimum components needed to answer the question.
- Verify: compare with a baseline or trusted implementation; save seeds, parameters, and raw outputs.
- Transfer: change one shape, dataset, scale, or workload condition and explain whether the conclusion still holds.