title: Slow division in cython
body: <p>In order to get fast division in cython, I can use the compiler directive</p>
  
  <pre><code>@cython.cdivision(True)
  </code></pre>
  
  <p>This works, in that the resulting c code has no zero division checking. However for some reason it is actually making my code slower. Here is an example:</p>
  
  <pre><code>@cython.boundscheck(False)
  @cython.wraparound(False)
  @cython.nonecheck(False)
  @cython.cdivision(True)
  def example1(double[:] xi, double[:] a, double[:] b, int D):
  
      cdef int k
      cdef double[:] x = np.zeros(D)
  
      for k in range(D):
          x[k] = (xi[k] - a[k]) / (b[k] - a[k]) 
  
      return x
  
  @cython.boundscheck(False)
  @cython.wraparound(False)
  @cython.nonecheck(False)
  def example2(double[:] xi, double[:] a, double[:] b, int D):
  
      cdef int k
      cdef double[:] x = np.zeros(D)
  
      for k in range(D):
          x[k] = (xi[k] - a[k]) / (b[k] - a[k]) 
  
      return x
  
  def test_division(self):
  
      D = 10000
      x = np.random.rand(D)
      a = np.zeros(D)
      b = np.random.rand(D) + 1
  
      tic = time.time()
      example1(x, a, b, D)
      toc = time.time()
  
      print 'With c division: ' + str(toc - tic)
  
      tic = time.time()
      example2(x, a, b, D)
      toc = time.time()
  
      print 'Without c division: ' + str(toc - tic)
  </code></pre>
  
  <p>This results in output:</p>
  
  <pre><code>With c division: 0.000194787979126
  Without c division: 0.000176906585693
  </code></pre>
  
  <p>Is there any reason why turning off zero division checking could slow down things (I know there are no zero divisors).</p>