~/talk

Iterating Efficiently in Python with itertools

TalkinSpanishat PyCon US 2025 · 2025-05-16..05-18· [python, developer-experience]
links:none on file
slides:none on file

Concrete examples of Python’s itertools are presented: using count, cycle, and repeat for infinite sequences and round‑robin patterns; chain and chain.from_iterable to flatten logs without loading whole files; and zip_longest with fillvalue to avoid losing data. Demonstrates lazy filtering and slicing with compress and islice, generating combinations, permutations, and Cartesian products (for brute‑force password enumerations), and shows a benchmark where 20,160 combinations drop from ~93.7 ms to ~15.1 ms using itertools while avoiding crashes from loading huge ranges into memory.

AI-written summary · about

  1. 0:00Welcome
  2. 1:25Efficient iteration
  3. 3:52Iterators and generators
  4. 8:06What are itertools
  5. 11:34Iteration tools
  6. 16:08Combining iterables
  7. 22:11Cartesian products and permutations
  8. 26:22Filtering and grouping
  9. 29:14Efficiency tips
  10. 31:21Conclusion
~/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.