Add a module itertools.recipes

Hello, A very useful part of the itertools module's documentation is the section "Recipes", giving utility functions that use itertools iterators. But when you want to use one of theese functions, you have to copy it in your source code (or use external PyPI modules like iterutils). Can we consider making itertools a package and adding a module itertools.recipes that implements all these utilility functions? Regards. -- Antoine Rozo

On Fri, Oct 13, 2017 at 11:35 AM, Chris Angelico <rosuav@gmail.com> wrote:
toolz is another good collection of itertools-related recipes: http://toolz.readthedocs.io/en/latest/api.html - Lucas

I am not searching for an external library (as I pointed, there are some on PyPI like iterutils or more-itertools). My point was that recipes are documented in itertools module, but not implemented in standard library, and it would be useful to have them available. 2017-10-13 20:35 GMT+02:00 Chris Angelico <rosuav@gmail.com>:
-- Antoine Rozo

On 14 October 2017 at 16:06, Antoine Rozo <antoine.rozo@gmail.com> wrote:
Not providing the recipes as an importable API is a deliberate design decision, as what folks often need is code that is similar-to-but-not-exactly-the-same-as the code in the recipe. If they've copied the code into their own utility library, then that's not a problem - they can just edit their version to have the exact semantics they need. Individual recipes may occasionally get promoted to be part of the module API, but that only happens on a case by case basis, and requires a compelling justification for the change ("It's sometimes useful" isn't compelling enough - we know it's sometimes useful, that's why it's listed as an example recipe). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia

On Fri, Oct 13, 2017 at 11:35 AM, Chris Angelico <rosuav@gmail.com> wrote:
toolz is another good collection of itertools-related recipes: http://toolz.readthedocs.io/en/latest/api.html - Lucas

I am not searching for an external library (as I pointed, there are some on PyPI like iterutils or more-itertools). My point was that recipes are documented in itertools module, but not implemented in standard library, and it would be useful to have them available. 2017-10-13 20:35 GMT+02:00 Chris Angelico <rosuav@gmail.com>:
-- Antoine Rozo

On 14 October 2017 at 16:06, Antoine Rozo <antoine.rozo@gmail.com> wrote:
Not providing the recipes as an importable API is a deliberate design decision, as what folks often need is code that is similar-to-but-not-exactly-the-same-as the code in the recipe. If they've copied the code into their own utility library, then that's not a problem - they can just edit their version to have the exact semantics they need. Individual recipes may occasionally get promoted to be part of the module API, but that only happens on a case by case basis, and requires a compelling justification for the change ("It's sometimes useful" isn't compelling enough - we know it's sometimes useful, that's why it's listed as an example recipe). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (4)
-
Antoine Rozo
-
Chris Angelico
-
Lucas Wiman
-
Nick Coghlan