~/talk

Loop better: a deeper look at iteration in Python

Talkat PyCon AU 2017 · 2017-08-03..08-08· [python]
slides:none on file

Shows that a generator like squares gets exhausted (tuple(squares) produces the numbers but sum(squares) after that returns 0) and that testing membership can consume it so `9 in squares` can be True then False, explains that unpacking a dict yields keys because unpacking uses iteration, demonstrates QuerySet.iterator to avoid Django queryset caching for large results, compares a hand-rolled iterator class to an equivalent generator function and generator expression, and recommends generators are iterators, iterators are their own iterables, and itertools.islice for lazy work.

AI-written summary · about

  1. 0:00Intro
  2. 0:32About me
  3. 1:20Problems
  4. 3:35Loops
  5. 8:25Iterators
  6. 10:14While loop
  7. 11:25Iterator protocol
  8. 12:12Why should we care
  9. 13:32Iterators are intervals
  10. 14:33Iterators are iterables
  11. 15:33Generators are iterators
  12. 16:00Why care about iterators
  13. 17:28Django query sets
  14. 19:15Django iterators
  15. 20:48For loop
  16. 26:28Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.