title: What happens in numpy's log function? Are there ways to improve the performance?
body: <p>I have a computation project with heavy use of log function (for integers), billions of calls. I find the performance of numpy's log is surprisingly slow.</p>
  
  <p>The following code takes 15 to 17 secs to complete:</p>
  
  <pre><code>import numpy as np
  import time
  
  t1 = time.time()
  for i in range(1,10000000): 
      np.log(i)
  t2 = time.time()
  print(t2 - t1)
  </code></pre>
  
  <p>However, the math.log function takes much less time from 3 to 4 seconds.</p>
  
  <pre><code>import math
  import time
  
  t1 = time.time()
  for i in range(1,10000000): 
      math.log(i)
  t2 = time.time()
  print(t2 - t1)
  </code></pre>
  
  <p>I also tested matlab and C#, which takes about 2 secs and just 0.3 secs respectively. </p>
  
  <p><strong>matlab</strong></p>
  
  <pre><code>tic
  for i = 1:10000000
      log(i);
  end
  toc
  </code></pre>
  
  <p><strong>C#</strong></p>
  
  <pre><code>var t = DateTime.Now;
  for (int i = 1; i &lt; 10000000; ++i)
       Math.Log(i);
  Console.WriteLine((DateTime.Now - t).TotalSeconds);
  </code></pre>
  
  <p>Is there any way in python that I can improve the performance of log function?</p>