# How do I make a jitclass with a jitted function member?

**URL:** <https://numba.discourse.group/t/how-do-i-make-a-jitclass-with-a-jitted-function-member/432>\
**Category:** Support: How do I do ...?\
**Created:** [January 13, 2021, 5:17pm UTC](https://numba.discourse.group/t/how-do-i-make-a-jitclass-with-a-jitted-function-member/432 "2021-01-13T17:17:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelson2005](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/nelson2005/32/47_2.png) [@nelson2005](https://numba.discourse.group/u/nelson2005)\
**Post date:** [January 13, 2021, 5:17pm UTC](https://numba.discourse.group/t/how-do-i-make-a-jitclass-with-a-jitted-function-member/432/1 "2021-01-13T17:17:54Z")

</div>

(moved from gitter)  
Is there a way to make a jitclass with a jit function member? In this case I’d like to\_be\_called to be some kind of pointer/reference to the jit function.

```python
from numba import njit, int64
from numba.experimental import jitclass

@jitclass([("to_be_called", int64)]) # what type goes here?
class Caller:
    def __init__ (self, to_be_called):
        self.to_be_called = to_be_called

    def call(self):
        # I'd like to write something like
        # return self.to_be_called()
        return 0

@njit(int64())
def to_be_called_impl():
    return 42

# caller = Caller(to_be_called_impl)
# caller.call()

```

In the gitter conversation, @stuartarchibald responded:

```python
from numba import njit, int64, typeof
from numba.experimental import jitclass

@njit(int64())
def to_be_called_impl():
    return 42

fty = typeof(to_be_called_impl)

@jitclass([("to_be_called", fty)])
class Caller:
    def __init__ (self, to_be_called):
        self.to_be_called = to_be_called

    def call(self):
        return self.to_be_called()

caller = Caller(to_be_called_impl)
print(caller.call())

```

and @luk-f-a responded with a link to

> [@Typed list of jitted functions in jitclass](https://numba.discourse.group/t/typed-list-of-jitted-functions-in-jitclass/413):
>
> I am trying to create a jitted class that contains a typed list of jitted functions. I have tried using the following in the spec: numba.types.List(numba.types.Callable) numba.typeof(mylist) where mylist is a List that contains a jitted function. but I cannot make it work. Any suggestions?

---

<div class="post-metadata">

**Author:** ![stuartarchibald](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/stuartarchibald/32/10_2.png) [@stuartarchibald](https://numba.discourse.group/u/stuartarchibald)\
**Post date:** [January 13, 2021, 5:23pm UTC](https://numba.discourse.group/t/how-do-i-make-a-jitclass-with-a-jitted-function-member/432/2 "2021-01-13T17:23:54Z")

</div>

Thanks for posting @nelson2005, it’s great to have this recorded! Original discussion is [here](https://gitter.im/numba/numba?at=5fff26a64498e01bbfa61a6a).
