Why does map return a map object instead of a list in Python 3?
<p>I am interested in understanding the <a href="http://stackoverflow.com/questions/1303347/getting-a-map-to-return-a-list-in-python-3-x">new language design of Python 3.x</a>.</p>

<p>I do enjoy, in Python 2.7, the function <code>map</code>:</p>

<pre><code>Python 2.7.12
In[2]: map(lambda x: x+1, [1,2,3])
Out[2]: [2, 3, 4]
</code></pre>

<p>However, in Python 3.x things have changed:</p>

<pre><code>Python 3.5.1
In[2]: map(lambda x: x+1, [1,2,3])
Out[2]: &lt;map at 0x4218390&gt;
</code></pre>

<p>I understand the how, but I could not find a reference to the why. Why did the language designers make this choice, which, in my opinion, introduces a great deal of pain. Was this to arm-wrestle developers in sticking to list comprehensions?</p>

<p>IMO, list can be naturally thought as <a href="http://learnyouahaskell.com/functors-applicative-functors-and-monoids" rel="nofollow">Functors</a>; and I have been somehow been thought to think in this way:</p>

<pre><code>fmap :: (a -&gt; b) -&gt; f a -&gt; f b
</code></pre>

<p>Because it returns an iterator, it omit storing the full list in the memory. So that you can easily iterate over it in the future not making pain to memory. Possibly you even don't need a full list, but the part of it, until your condition is matched.</p>

<p>You can find this <a href="https://docs.python.org/3/glossary.html#term-iterator">docs</a> useful, because iterators are awesome.</p>

<blockquote>
  <p>An object representing a stream of data. Repeated calls to the iteratorâs <code>__next__()</code> method (or passing it to the built-in function <code>next()</code>) return successive items in the stream. When no more data are available a <code>StopIteration</code> exception is raised instead. At this point, the iterator object is exhausted and any further calls to its <code>__next__()</code> method just raise <code>StopIteration</code> again. Iterators are required to have an <code>__iter__()</code> method that returns the iterator object itself so every iterator is also iterable and may be used in most places where other iterables are accepted. One notable exception is code which attempts multiple iteration passes. A container object (such as a <code>list</code>) produces a fresh new iterator each time you pass it to the <code>iter()</code> function or use it in a for loop. Attempting this with an iterator will just return the same exhausted iterator object used in the previous iteration pass, making it appear like an empty container. </p>
</blockquote>

python python-3.x