Fate of itertools.dropwhile() and itertools.takewhile()

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Dec 29 20:11:03 EST 2007


On Sat, 29 Dec 2007 15:10:24 -0800, Raymond Hettinger wrote:

> * Both functions seem simple and basic until you try to explain them to
> someone else.

Oh I don't know about that. The doc strings seem to do an admirable job 
to me. Compared to groupby(), the functions are simplicity themselves.


> Likewise, when reading code containing dropwhile(), I
> don't think it is self-evident that dropwhile() may have a lengthy
> start-up time.

*scratches head in confusion*

It isn't? I can understand somebody *under*estimating the start-up time 
(perhaps because they overestimate how quickly dropwhile() can iterate 
through the items). But surely it is self-evident that a function which 
drops items has to drop the items before it can start returning?


> * Since itertools are meant to be combined together, the whole module
> becomes easier to use if there are fewer tools to choose from.

True, but on the other hand a toolbox with too few tools is harder to use 
than one with too many tools.



-- 
Steven



More information about the Python-list mailing list