title: How to specify function signature for a method using custom types in numba
body: <p>I use the <code>numba.jitclass</code> decorator to mark my class for optimization.</p>
  
  <p>I don't know how to specify the signature of the <code>run</code> method that I want to optimize. The method takes an array of <code>ConvertedDocument</code> objects as an argument. It seems that numba is not able to figure out the array type on its own as the following error occurs when I try to invoke the run method in a nopython mode:</p>
  
  <pre><code>Traceback (most recent call last):
    File "numba_test.py", line 53, in &lt;module&gt;
      print run(a)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/dispatcher.py", line 310, in _compile_for_args
      raise e
  numba.errors.TypingError: Caused By:
  Traceback (most recent call last):
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/compiler.py", line 230, in run
      stage()
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/compiler.py", line 444, in stage_nopython_frontend
      self.locals)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/compiler.py", line 800, in type_inference_stage
      infer.propagate()
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 767, in propagate
      raise errors[0]
  TypingError: Internal error at &lt;numba.typeinfer.ExhaustIterConstraint object at 0x788cc9572d50&gt;:
  --%&lt;-----------------------------------------------------------------
  Traceback (most recent call last):
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 128, in propagate
      constraint(typeinfer)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 264, in __call__
      raise TypingError("failed to unpack {}".format(tp), loc=self.loc)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/contextlib.py", line 35, in __exit__
      self.gen.throw(type, value, traceback)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/errors.py", line 249, in new_error_context
      six.reraise(type(newerr), newerr, sys.exc_info()[2])
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/errors.py", line 243, in new_error_context
      yield
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 264, in __call__
      raise TypingError("failed to unpack {}".format(tp), loc=self.loc)
  InternalError: local variable 'tp' referenced before assignment
  [1] During: typing of exhaust iter at numba_test.py (40)
  --%&lt;-----------------------------------------------------------------
  
  File "numba_test.py", line 40
  
  Failed at nopython (nopython frontend)
  Internal error at &lt;numba.typeinfer.ExhaustIterConstraint object at 0x788cc9572d50&gt;:
  --%&lt;-----------------------------------------------------------------
  Traceback (most recent call last):
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 128, in propagate
      constraint(typeinfer)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 264, in __call__
      raise TypingError("failed to unpack {}".format(tp), loc=self.loc)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/contextlib.py", line 35, in __exit__
      self.gen.throw(type, value, traceback)
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/errors.py", line 249, in new_error_context
      six.reraise(type(newerr), newerr, sys.exc_info()[2])
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/errors.py", line 243, in new_error_context
      yield
    File "/home/clasocki/anaconda2/envs/my_numba_env/lib/python2.7/site-packages/numba/typeinfer.py", line 264, in __call__
      raise TypingError("failed to unpack {}".format(tp), loc=self.loc)
  InternalError: local variable 'tp' referenced before assignment
  [1] During: typing of exhaust iter at numba_test.py (40)
  --%&lt;-----------------------------------------------------------------
  
  File "numba_test.py", line 40
  
  This error may have been caused by the following argument(s):
  - argument 0: Unsupported array dtype: object
  </code></pre>
  
  <p>Here's how I specify the numba decorators:</p>
  
  <pre><code>spec = [
      ('profile', numba.typeof(numpy.asarray([1.0, 2.0]))),
      ('word_weights', numba.typeof(numpy.asarray([(1.0,2.0)])))
  ]
  
  @numba.jitclass(spec)
  class ConvertedDocument(object):
      def __init__(self, profile, word_weights):
          self.profile = profile
          self.word_weights = word_weights
  
  @numba.jit(nopython=True,cache=True)
  def run(docs):
      s = 0
      for doc in docs: #array of documents
          for w_id, weight in doc.word_weights: #accessing document's property
              s += weight
  
      return s
  </code></pre>
  
  <p>And this is the way the <code>run</code> method is called:</p>
  
  <pre><code>x = numpy.asarray([1.0, 2.0])
  y = numpy.asarray([(1.0,2.0), (3.0,4.0)])
  a = numpy.asarray([ConvertedDocument(x,y)])
  print run(a)
  </code></pre>
  
  <p>If the <code>a</code> numpy array is replaced with a Python list, the exception is as follows:</p>
  
  <pre><code>Failed at nopython (nopython mode backend)
  reflected list(instance.jitclass.ConvertedDocument#3bffb70&lt;profile:array(float64, 1d, C),word_weights:array(float64, 2d, C)&gt;): unsupported nested memory-managed object
  </code></pre>
  
  <p>Does anyone know how to specify a method signature when custom types are used or whether the iteration over an array of objects is supported or not?</p>