title: Why does completely same function behave differently in ipython/jupyter?
body: <p>I have two identical functions, say, <code>sum_nb</code> and <code>sum_nb2</code>. I define them with <code>@njit</code> decorator:</p>
  <pre class="lang-py prettyprint-override"><code>from numba import njit
  from timeit import timeit
  
  @njit
  def sum_nb(n=100_000_000):
      s = 0
      for i in range(n):
          s += i
      return s
  
  @njit
  def sum_nb2(n=100_000_000):
      s = 0
      for i in range(n):
          s += i
      return s
  </code></pre>
  <p>if I just save as script and add code to measure execution time, everything behaves nicely:</p>
  <pre class="lang-py prettyprint-override"><code>print(sum_nb())
  print(sum_nb2())
  print(timeit(sum_nb))
  print(timeit(sum_nb2))
  </code></pre>
  <p>The output is:</p>
  <pre><code>4999999950000000
  4999999950000000
  0.41249959499691613
  0.4120563520118594
  </code></pre>
  <p>Now I open ipython console/jupyter lab and copy the first code to the cell. Then I measure code time in cells with magic:</p>
  <pre><code>In [3]: %timeit sum_nb()
  240 ns ± 86.5 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
  
  In [4]: %timeit sum_nb2()
  7.32 µs ± 90 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
  </code></pre>
  <p>The same happens if in jupyter lab. How does it happen? How it works? Why does the same code have different speed?</p>
  <p>I have ipython 7.7.0, numba 0.44.1, python 3.7.3, jupyter lab 1.0.2</p>