I'm using numba's @jitclass and I want to reduce the compilation time.
For example (my actual class is much bigger):
@jitclass
class State:
a: int
b: int
def __init__(self):
a = 0
b = 0
def update(self, x: int):
self.a += x
self.b -= x
I tried adding the cache parameter to @jitclass, but it seems that it isn't supported.
@jitclass(cache=True)
class State:
...
I also tried to change my class just to hold data, and compile all methods with @njit with cache:
@jitclass
class State:
a: int
b: int
def __init__(self):
a = 0
b = 0
@njit(cache=True)
def update(state: State, x: int):
state.a += x
state.b -= x
But this seems to make compilation time even worse. My guess is that because State isn't cached it compiles each time, and then the dependent functions requires compilation.
Is there any solution that reduces this compilation time?