<div dir="auto"><div>A proposal to make map() not return an iterator seems like a non-starter. Yes, Python 2 worked that way, but that was a long time ago and we know better now.</div><div dir="auto"><br></div><div dir="auto">In the simple example it doesn't matter much:</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">  mo = map(lambda x: x, "aardvark")</span><br></div><div dir="auto"><br></div><div dir="auto">But map() is more useful for the non-toy case:</div><div dir="auto"><br></div><div dir="auto">  mo = map(expensive_db_lookup, list_of_keys)</div><div dir="auto"><br></div><div dir="auto">list_of_keys can be a concrete list, but I'm using map() mainly specifically to get lazy iterator behavior.</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Sat, Dec 1, 2018, 11:10 AM Paul Svensson <<a href="mailto:paul-python@svensson.org">paul-python@svensson.org</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, 1 Dec 2018, Steven D'Aprano wrote:<br>
<br>
> On Thu, Nov 29, 2018 at 08:13:12PM -0500, Paul Svensson wrote:<br>
><br>
>> What's being proposed is simple, either:<br>
>>  * len(map(f, x)) == len(x), or<br>
>>  * both raise TypeError<br>
><br>
> Simple, obvious, and problematic.<br>
><br>
> Here's a map object I prepared earlier:<br>
><br>
> from itertools import islice<br>
> mo = map(lambda x: x, "aardvark")<br>
> list(islice(mo, 3))<br>
><br>
> If I now pass you the map object, mo, what should len(mo) return? Five<br>
> or eight?<br>
<br>
mo = "aardvark"<br>
list(islice(mo, 3))<br>
<br>
By what magic would the length change?<br>
Per the proposal, it can only be eight.<br>
Of course, that means mo can't, in this case, be an iterator.<br>
That's what the proposal would change.<br>
<br>
        /Paul<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div></div>