bschubert
(Brian Schubert)
April 23, 2024, 4:47pm
3
I found at least one previous proposal for this: [Python-Dev] Proposal for a new itertools function: iwindow
Additions to itertools
(and in particular converting recipes to module functions) are a fairly common type of suggestion. It would help your proposal if you could find and address some of the concerns that have been expressed in the past. See for example the discussion thread that lead to itertools.batched
:
Batching of lists, arrays, iterables, etc. is a pretty common operation, which is why I was surprised that this functionality has not already been implemented as part of the itertools module when I recently went looking for it! I feel like batching functionality is simple enough that it wouldn’t be too difficult to implement, and could be used across a wide variety of tasks, but complex enough that it would be nice to have a known solid reference implementation as part of the standard library ra…
Also:
I’m not really sure if this is the right place to ask this, but I’m kind of confused about why the itertools module has recipes like grouper and sliding_window in the documentation, rather than in the module itself.
I know that the itertools module itself is written in C for performance reasons, and the recipes are written in pure-Python but make use of code written in C (e.g. grouper calls zip_longest) so they’re presumably “fast enough” without needing to be written in C, but I’m not asking “…
1 Like