title: What are the advantages of using numpy.identity over numpy.eye?
body: <p>Having looked over the man pages for <code>numpy</code>'s <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.eye.html" rel="noreferrer"><code>eye</code></a> and <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.identity.html" rel="noreferrer"><code>identity</code></a>, I'd assumed that <code>identity</code> was a special case of <code>eye</code>, since it has fewer options (e.g. <code>eye</code> can fill shifted diagonals, <code>identity</code> cannot), but could plausibly run more quickly. However, this isn't the case on either small or large arrays:</p>
  <pre><code>&gt;&gt;&gt; np.identity(3)                                                  
  array([[ 1.,  0.,  0.],
         [ 0.,  1.,  0.],
         [ 0.,  0.,  1.]])
  &gt;&gt;&gt; np.eye(3)                                                       
  array([[ 1.,  0.,  0.],
         [ 0.,  1.,  0.],
         [ 0.,  0.,  1.]])
  &gt;&gt;&gt; timeit.timeit(&quot;import numpy; numpy.identity(3)&quot;, number = 10000)
  0.05699801445007324
  &gt;&gt;&gt; timeit.timeit(&quot;import numpy; numpy.eye(3)&quot;, number = 10000)     
  0.03787708282470703
  &gt;&gt;&gt; timeit.timeit(&quot;import numpy&quot;, number = 10000)                   
  0.00960087776184082
  &gt;&gt;&gt; timeit.timeit(&quot;import numpy; numpy.identity(1000)&quot;, number = 10000)
  11.379066944122314
  &gt;&gt;&gt; timeit.timeit(&quot;import numpy; numpy.eye(1000)&quot;, number = 10000)     
  11.247124910354614
  </code></pre>
  <p>What, then, is the advantage of using <code>identity</code> over <code>eye</code>?</p>