@numba.jitclass({'i': numba.uint64})
class State(object):

    def __init__(self):
        self.i = 0

def square_plus_count(self, x):
    self.i += 1
return x ** 2 + self.i
square_with_call_count = State().square_plus_count
print([square_with_call_count(i) for i in range(10)])
Корутины в numba