On Tue, Nov 27, 2018 at 12:37 PM Kale Kundert <k...@thekunderts.net> wrote:
> I guess I probably would have disagreed with the decision to make map() an
> iterator rather than a wrapper around an iterable.  Such a prominent function
> should have an API geared towards usability, not towards implementing a
> low-level protocol (in my opinion).  But clearly that ship has sailed.

For map() returns an iterable that can be used more than once, it has
to be mapping over an iterable that can be used more than once. That
limits it. The way map is currently defined, it can accept any
iterable, and it returns a one-shot iterable (which happens to be its
own iterator). That's why I think the best solution is to create a
separate mapped-sequence-view that depends on its iterable being an
actual sequence, and exposes itself as a sequence also. (Yes, I said
"list" in my previous post, but any sequence would work.) It can carry
the length through, it can directly support subscripting, etc, etc,
etc. Both it and map() would have their places.

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to