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 “why aren’t they implemented in C”.
There could be, say, a itertools.recipes
submodule of pure Python code which contains those recipes, and that would, at least at first glance, seem to make more sense than including them in the module documentation and making people copy-paste them when they need them.
But, I suspect that if such an obvious option wasn’t taken that there’s a reason for it. So, what is the reason that the recipes are provided via the documentation?
Also, as a follow-up question, are there any other modules in the stdlib that do something similar?