# Can't iterate over heterogeneous tuple of jitted functions

**URL:** <https://numba.discourse.group/t/cant-iterate-over-heterogeneous-tuple-of-jitted-functions/2011>\
**Category:** Support: How do I do ...?\
**Created:** [July 14, 2023, 11:32am UTC](https://numba.discourse.group/t/cant-iterate-over-heterogeneous-tuple-of-jitted-functions/2011 "2023-07-14T11:32:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyu](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/dyu/32/1046_2.png) [@dyu](https://numba.discourse.group/u/dyu)\
**Post date:** [July 14, 2023, 11:32am UTC](https://numba.discourse.group/t/cant-iterate-over-heterogeneous-tuple-of-jitted-functions/2011/1 "2023-07-14T11:32:28Z")

</div>

Hi,  
I need to be able to iterate over a heterogeneous tuple of jitted functions. I tried using `numba.unroll_literal` but that didn’t work. Below is my code and the error I get. How can I do this?

```python
@numba.njit
def f1():
    return 4

@numba.njit
def f2():
    return 1

@numba.njit
def combine(func_tuple):
    for i in range(len(func_tuple)):
        print(func_tuple[i]())

```

Error:

```auto
Traceback (most recent call last):
  File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
    exec(code, self.locals)
  File "<pyshell#120>", line 1, in <module>
  File "/home/dyuman/.local/lib/python3.10/site-packages/numba/core/dispatcher.py", line 468, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/home/dyuman/.local/lib/python3.10/site-packages/numba/core/dispatcher.py", line 409, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
e[1me[1mNo implementation of function Function(<built-in function getitem>) found for signature:
 
 >>> getitem(Tuple(type(CPUDispatcher(<function f2 at 0x7f58de43a710>)), type(CPUDispatcher(<function f3 at 0x7f58a88ccdc0>))), int64)
 
There are 22 candidate implementations:
e[1m - Of which 22 did not match due to:
      Overload of function 'getitem': File: <numerous>: Line N/A.
        With argument(s): '(Tuple(type(CPUDispatcher(<function f2 at 0x7f58de43a710>)), type(CPUDispatcher(<function f3 at 0x7f58a88ccdc0>))), int64)':e[0m
e[1m No match.e[0m
e[0m
e[0me[1mDuring: typing of intrinsic-call at <pyshell#119> (4)e[0m
e[1m
File "<pyshell#119>", line 4:e[0m
e[1m<source missing, REPL/exec in use?>e[0m

```

---

<div class="post-metadata">

**Author:** ![sschaer](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sschaer](https://numba.discourse.group/u/sschaer)\
**Post date:** [July 14, 2023, 1:05pm UTC](https://numba.discourse.group/t/cant-iterate-over-heterogeneous-tuple-of-jitted-functions/2011/2 "2023-07-14T13:05:04Z")

</div>

Hi @dyu

Is it possible that you have used `numba.literal_unroll` inside `combine`? If so, Numba cannot handle the `numba` module inside the jitted function. However, the following works:

```auto
import numba as nb 
from numba import literal_unroll

@nb.njit
def f1():
    return 4

@nb.njit
def f2():
    return 1

@nb.njit
def combine(func_tuple):
    for i in range(len(literal_unroll(func_tuple))):
        print(func_tuple[i]())
        
combine((f1, f2))

```

---

<div class="post-metadata">

**Author:** ![dyu](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/dyu/32/1046_2.png) [@dyu](https://numba.discourse.group/u/dyu)\
**Post date:** [July 15, 2023, 3:37am UTC](https://numba.discourse.group/t/cant-iterate-over-heterogeneous-tuple-of-jitted-functions/2011/3 "2023-07-15T03:37:18Z")

</div>

@sschaer Thank you so much for your reply!

You were right, I was using `numba.literal_unroll`. I made the modification you suggested and it works!

Thanks again,  
Dyuman
