Loading topic
yield are helpful background but not required.5 min readitertools: count, cycle and repeat. It assumes you can write functions, loops and comprehensions, and that you know what an iterator is and that one is consumed after a single pass. Generators and yield are helpful background but not requ6 min readkey= argument of sorted. You should also know the difference between an iterable and an iterator, and that an iterator is used up after one full pass. Earlier chapters covered count, cycle and repeat. Tho5 min readlambda predicate, and that you have seen islice and count from earlier chapters. The four tools here filter an iterator without building a list. Two of them decide by position in the stream (6 min readitertools that apply a function to a stream as it flows past. accumulate carries a value forward from one item to the next. starmap unpacks each item into the arguments of a call.5 min readzip, tuple unpacking in for loops, and the iterator protocol from the first chapter (an iterator is consumed as you read it). You should also know how itertools tools stay lazy, which the earlier chapters on lazy evaluation covered.5 min readlambda and the key= argument of sorted. You should also know what an iterator is and that it can be consumed only once. Both ideas matter here, because groupby is lazy and its output depend6 min readproduct, permutations and combinations. It also covers the related combinations_with_replacement. It assumes you are comfortable with loops, tuples and comprehensions, and that you know an iterator is consumed o6 min readnext() and the idea that an iterator is used up after one pass. Generators and yield help but are not required.6 min readfor loop, list(), sum() or next() asks for a value. This chapter shows how to combine the tools from earlier cha6 min readgroupby, tee, and pipelines. You should be comfortable with generators, comprehensions, and the key= argument of sorted. The tools in itertools are fast and use little memory. Most bugs with them come from three properti6 min read