#itertools Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
Python take / drop / takewhile
Take the first N items of an iterable (or while a predicate holds). drop is the complement. Lazy via islice + itertools.dropwhile — works on infinite generators.
Python chunked — Split Iterable into Fixed-Size Pieces
Lazy chunker that works on any iterable, not just lists. Common building block for batch APIs — "send 50 rows per request" — without loading the source into memory.
Python pairwise — Rolling Pair Iterator
`pairwise([a, b, c, d])` yields `(a, b), (b, c), (c, d)` — built into itertools since 3.10. Perfect for "diff consecutive elements" patterns (deltas, rate-of-change, validation between rows).