On 4/05/23 9:29 am, Chris Angelico wrote:
So
you're asking for map to be able to return an iterator if given an
iterator, or an adapter if given an adapter. That makes it quite
complicated to use and reason about.

Also a bit slower, since it would need to inspect its argument
and decide what to do with it. Currently it can just get on
with its job and rely on duck typing to do the right thing.

Maybe there could be a parallel set of functions "enumerated",
"mapped", etc. that take sequences and return sequence views.

Although that naming convention would suggest that reversed()
itself should return a sequence view rather than an iterator.
That would require restricting it to working on sequences,
which would be an incompatible change.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to