title: Cython: declare list-like function parameter
body: <p>I'm trying to create a simple cython module and have the following problem. I would like to create a function like:</p>
  
  <pre><code>cdef float calc(float[:] a1, float[:] a2):
      cdef float res = 0
      cdef int l = len(a2)
      cdef float item_a2
      cdef float item_a1
  
      for idx in range(l):
          if a2[idx] &gt; 0:
              item_a2 = a2[idx]
              item_a1 = a1[idx]
              res += item_a2 * item_a1
  
      return res
  </code></pre>
  
  <p>When the function is being executed, a1 and a2 params are python lists. Therefore I get the error:</p>
  
  <blockquote>
    <p>TypeError: a bytes-like object is required, not 'list'</p>
  </blockquote>
  
  <p>I just need to make such calculations and nothing more. But how shall I define input params <code>float[:] a1</code> and <code>float[:] a2</code> if I need to maximize speed up using C?
  Probably it's necessary to convert lists to arrays manually?</p>
  
  <p>P.S. would appreciate also if you can also explain to me whether it's necessary  to declare <code>cdef float item_a2</code> explicitly to perform multiplication (in terms of performance) or it is equally to <code>result += a2[idx] * a1[idx]</code></p>