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>Guido answers this question <a href="https://docs.python.org/3/whatsnew/3.0.html">here</a>: "<em>since creating a list would just be wasteful</em>".  </p>

<p>He also says that the correct transformation is to use a regular <code>for</code> loop.</p>

<p>Converting <code>map()</code> from 2 to 3 might not just be a simple case of sticking a <code>list( )</code> around it.  Guido also says:</p>

<p>"If the input sequences are not of equal length, <code>map()</code> will stop at the termination of the shortest of the sequences. For full compatibility with <code>map()</code> from Python 2.x, also wrap the sequences in <code>itertools.zip_longest()</code>, e.g.</p>

<pre><code>map(func, *sequences)
</code></pre>

<p>becomes  </p>

<pre><code>list(map(func, itertools.zip_longest(*sequences)))
</code></pre>

<p>"</p>

python python-3.x