On Saturday, July 1, 2017, Steven D'Aprano
On Fri, Jun 30, 2017 at 01:09:51AM +0200, Jan Kaliszewski wrote:
[...]
But the more I think about it the more I agree with Nick. Let's start by moving itertools.chain into built-ins, with zip and map, and only consider giving it an operator after we've had a few years of experience with chain as a built-in. We might even find that an operator doesn't add any real value.
- Would that include chain.from_iterable? - So there's then a new conditional import (e.g. in a compat package)? What does this add?
¹ Preferably using the existing `yield from` mechanism -- because, in case of generators, it would provide a way to combine ("concatenate") *generators*, preserving semantics of all that their __next__(), send(), throw() nice stuff...
I don't think that would be generally useful.
Flatten one level?
If you're sending values into an arbitrary generator, who knows what you're getting? chain() will operate on arbitrary iterables, you can't expect to send values into chain([1, 2, 3], my_generator(), "xyz") and have anything sensible occur.
- is my_generator() mutable (e.g. before or during iteration)? - https://docs.python.org/2/reference/expressions.html#generator.send