On Sat, 1 Dec 2018, Steven D'Aprano wrote:

On Thu, Nov 29, 2018 at 08:13:12PM -0500, Paul Svensson wrote:

What's being proposed is simple, either:
 * len(map(f, x)) == len(x), or
 * both raise TypeError

Simple, obvious, and problematic.

Here's a map object I prepared earlier:

from itertools import islice
mo = map(lambda x: x, "aardvark")
list(islice(mo, 3))

If I now pass you the map object, mo, what should len(mo) return? Five
or eight?

mo = "aardvark"
list(islice(mo, 3))

By what magic would the length change?
Per the proposal, it can only be eight.
Of course, that means mo can't, in this case, be an iterator.
That's what the proposal would change.

       /Paul
_______________________________________________
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