Tug-of-Code: The battle for efficient iteration in Go
summary
Explains how Go now lets code range over function with exactly three allowed function signatures and shows concrete APIs: a generic sec type (one-value) and a two-value seek two variant, plus push vs pull iterator patterns and when to prefer each. Presents a simple gen10 example, adapter use cases (zip, map, chain) and a public benchmark iterating 100k items that drops memory from ~3 MB to under 1 MB. Warns about extra allocations, chaining costs, and recommends benchmarking.
AI-written summary · about
chapters (17)
- 0:00Introduction and speaker intro
- 1:10Why iterators matter in Go
- 3:38Iteration recap in Go
- 7:56Range over functions explained
- 10:05Implementing range over functions
- 13:21Naming the sequence type
- 14:47Seek two for key-value pairs
- 15:51Understanding yield in iterators
- 17:59Push vs pull iteration models
- 21:36When to use pull iterators
- 22:41Iterators in standard library
- 24:06Performance benefits of iterators
- 25:32Iterators performance caveats
- 26:37Anti-patterns to avoid
- 27:40Final thoughts on iterators
- 29:50Go's simplicity vs complexity
- 30:32Q&A session begins
