I am trying to create a class similar to the one below.
spec = [("x", nb.float64), ("y", nb.float64)] @nb.experimental.jitclass(spec = spec) class MyClass: def __init__(self, x, square): self.x = x if square: f = self.x_squared else: f = self.x_simple self.y = f() def x_simple(self): return self.x def x_squared(self): return self.x**2 object = MyClass(x = 2.1, square = True) print("x = ", object.x) print("y = ", object.y)
But it raises an error when trying to compile the call of the f function. Is there a way to use a variable inside a jitclass as a function pointer to the methods of the same jitclass?
Thank you for your help,