Numba jitclass and inheritance
<p>I have an hierarchy of classes and I would like to speed up my code by using Numba jitclass. I have tested @jitclass for some examples without class inheritance and it works properly and speed up the code. However, if I have class inheritance the error occurred during the compilation. Below is the sample code demonstrating the problem. I would be very grateful for any comments and suggestions. Now for me it looks like class inheritance does not supported by Numba, but I did not find any information on it in documentation.
Code example:</p>

<pre><code>import numpy as np
from numba import jitclass         
from numba import int32, float32

spec = [
    ('n', int32),               
    ('val', float32[:]),          
]

@jitclass(spec)
class Parent(object):
    def __init__(self, n):
        self.n = n
        self.val = np.zeros(n, dtype=np.float32)

spec = [
    ('incr', float32),          
]

@jitclass(spec)
class Child(Parent):
    def __init__(self, n):
        Parent.__init__(self, n)
        self.incr = 2.

def func(self):
    for i in xrange(0, self.n):
        self.val[i] += self.incr
    return self.val

par = Parent(10)
chl = Child(10)
print chl.func()
</code></pre>

<p>The error I got is:</p>

<pre><code>TypeError: cannot subclass from a jitclass
</code></pre>

<p>Currently (as of 0.28.1), Numba does not support subclassing/inheriting from a <code>jitclass</code>. It's not stated in the documentation but the error message is pretty explicit. I'm guessing this capability will be added sometime in the future, but right now it's a limitation.</p>

python inheritance numba