title: Trouble with speeding up functions with numba JIT
body: <p>I am new to numba's jit. For a personal project, I need to speed up functions that are similar to what will be shown below, though different for the purpose of writing standalone examples.</p>
  
  <pre><code>import numpy as np
  from numba import jit, autojit, double, float64, float32, void
  
  def f(n):
      k=0.
      for i in range(n):
          for j in range(n):
              k+= i+j
  
  def f_with_return(n):
      k=0.
      for i in range(n):
          for j in range(n):
              k+= i+j
      return k
  
  def f_with_arange(n):
      k=0.
      for i in np.arange(n):
          for j in np.arange(n):
              k+= i+j
  
  def f_with_arange_and_return(n):
      k=0.
      for i in np.arange(n):
          for j in np.arange(n):
              k+= i+j  
  
  
  #jit decorators
  jit_f = jit(void(int32))(f)
  jit_f_with_return = jit(int32(int32))(f_with_return)
  jit_f_with_arange = jit(void(double))(f_with_arange)
  jit_f_with_arange_and_return = jit(double(double))(f_with_arange_and_return)
  </code></pre>
  
  <p>And the benchmarks:</p>
  
  <pre><code>%timeit f(1000)
  %timeit jit_f(1000)
  </code></pre>
  
  <p>10 loops, best of 3: 73.9 ms per loop / 1000000 loops, best of 3: 212 ns per loop</p>
  
  <pre><code>%timeit f_with_return(1000)
  %timeit jit_f_with_return(1000)
  </code></pre>
  
  <p>10 loops, best of 3: 74.9 ms per loop / 1000000 loops, best of 3: 220 ns per loop</p>
  
  <p><strong>I don't understand these two:</strong></p>
  
  <pre><code>%timeit f_with_arange(1000.0)
  %timeit jit_f_with_arange(1000.0)
  </code></pre>
  
  <p>10 loops, best of 3: 175 ms per loop / 1 loops, best of 3: 167 ms per loop</p>
  
  <pre><code>%timeit f_with_arange_with_return(1000.0)
  %timeit jit_f_with_arange_with_return(1000.0)
  </code></pre>
  
  <p>10 loops, best of 3: 174 ms per loop / 1 loops, best of 3: 172 ms per loop</p>
  
  <p>I think I'm not giving the jit function the correct types for the output and input ? Just because the for loop is now running over a numpy.arange, and not a simple range anymore, I cannot get jit to make it faster. What is the issue here ?</p>