2 ms·
Speaking of standard lib, today I was looking to do a sliding window over an iterator and ended up on the pairwise function in itertools that was added in 3.10.
by wodenokoto 4y ago
Speaking of standard lib, today I was looking to do a sliding window over an iterator and ended up on the pairwise function in itertools that was added in 3.10.
Seems like such a wasted opportunity, to add a sliding window for n=2, and then in the documentation add a recipe for a sliding window function for any n.
- talideon 4y agoThere are a lot of things like this in the boltons library: https://boltons.readthedocs.io/en/latest/iterutils.html#boltons.iterutils.windowed_iter https://boltons.readthedocs.io/en/latest/iterutils.html#bolt... It's nice to not have to depend on anything external, but boltons is something I just treat as an expanded part of the standard library.