title: Python/Numba - Custom class object as input type
body: <p>I'm starting with <code>numba</code> and my first goal is to try and accelerate a not so complicated function with a nested loop.  </p>
  
  <p>Given the following class:</p>
  
  <pre><code>class TestA:
      def __init__(self, a, b):
          self.a = a
          self.b = b
  
      def get_mult(self):
          return self.a * self.b
  </code></pre>
  
  <p>and a <code>numpy ndarray</code> that contains class <code>TestA</code> objects. Dimension <code>(N,)</code> where <code>N</code> is usually ~3 million in length.  </p>
  
  <p>Now given the following function:  </p>
  
  <pre><code>def test_no_jit(custom_class_obj_container):
      container_length = len(custom_class_obj_container)
      sum = 0
      for i in range(container_length):
          for j in range(i + 1, container_length):
              obj_i = custom_class_obj_container[i]
              obj_j = custom_class_obj_container[j]
              sum += (obj_i.get_mult() + obj_j.get_mult())
  
      return sum
  </code></pre>
  
  <p>I've tried to play around <code>numba</code> to get it to work with the function above however I cannot seem to get it to work with <code>nopython=True</code> flag, and if it's set to false, then the runtime is higher than the no-jit function.  </p>
  
  <p>Here is my latest try in trying to <code>jit</code> the function (also using nb.prange):  </p>
  
  <pre><code>@nb.jit(nopython=False, parallel=True)
  def test_jit(custom_class_obj_container):
      container_length = len(custom_class_obj_container)
      sum = 0
      for i in nb.prange(container_length):
          for j in nb.prange(i + 1, container_length):
              obj_i = custom_class_obj_container[i]
              obj_j = custom_class_obj_container[j]
              sum += (obj_i.get_mult() + obj_j.get_mult())
  
      return sum
  </code></pre>
  
  <p>I've tried to search around but I cannot seem to find a tutorial of how to define a custom class in the signature, and how would I go in order to accelerate a function of that sort and get it to run on GPU and possibly (any info regarding that matter would be highly appreciated) to get it to run with <code>cuda</code> libraries - which are installed and ready to use (previously used with <code>tensorflow</code>)</p>