How to specify the type signature of funtion pointers to jitclass member function

Hello @seekiu

Just a very quick note. I wouldn’t worry about that little overhead. Calling a jitclass method is most likely already a bit slower than calling a normal function. An indirect call can slow you down even more. I complicates optimizations further down the line. I would definitely leave it at the if statement and see if there is more room for improvement elsewhere. Numba and function pointers are usually not so trivial to handle. There was a discussion some time ago that you might find interesting and perhaps even useful:

As I said, I would go for the simple solution. However, depending on your actual problem (I assume you showed something simplified) you can try a branchless version:

def func(self, x):
        return (x + x + self.a, x * x)[nb.uint8(self.a > 1e-6)]

Whether a branchless version is faster depends on many things. So just try it out but with your real problem.