# Jitclass with input of list of jitclass

**URL:** <https://numba.discourse.group/t/jitclass-with-input-of-list-of-jitclass/475>\
**Category:** Community Support\
**Created:** [January 28, 2021, 12:42am UTC](https://numba.discourse.group/t/jitclass-with-input-of-list-of-jitclass/475 "2021-01-28T00:42:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![justinblaber](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/justinblaber/32/214_2.png) [@justinblaber](https://numba.discourse.group/u/justinblaber)\
**Post date:** [January 28, 2021, 12:42am UTC](https://numba.discourse.group/t/jitclass-with-input-of-list-of-jitclass/475/1 "2021-01-28T00:42:30Z")

</div>

Say I have a class:

```auto
@numba.experimental.jitclass([
    ('foo', numba.int64),
])
class foo(object):
    def __init__ (self, foo):
        self.foo = foo

```

And another class which takes, as input, a list of these classes:

```auto
@numba.experimental.jitclass([
    ('bar', numba.types.ListType(foo)),
])
class bar(object):
    def __init__ (self, bar):
        self.bar = bar

bar(numba.typed.List([foo(1)]))

```

Doing the above results in an error. I can fix it by doing:

```auto
@numba.experimental.jitclass([
    ('bar', numba.types.ListType(numba.typeof(foo(1)))),
])
class bar(object):
    def __init__ (self, bar):
        self.bar = bar

bar(numba.typed.List([foo(1)]))

```

But I don’t like having to instantiate a class like `foo(1)` and using `numba.typeof`. Is there a way to do the above without having to instantiate the class and using `typeof`?

---

<div class="post-metadata">

**Author:** ![Hannes](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/hannes/32/188_2.png) [@Hannes](https://numba.discourse.group/u/Hannes)\
**Post date:** [January 28, 2021, 8:40am UTC](https://numba.discourse.group/t/jitclass-with-input-of-list-of-jitclass/475/2 "2021-01-28T08:40:05Z")

</div>

Hi Justin,

I think your question has been answered here: [How do I create a jitclass that takes a list of jitclass objects?](https://numba.discourse.group/t/how-do-i-create-a-jitclass-that-takes-a-list-of-jitclass-objects/366)

Jitclasses have a field called `instance_type` that should help you here.

---

<div class="post-metadata">

**Author:** ![justinblaber](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/justinblaber/32/214_2.png) [@justinblaber](https://numba.discourse.group/u/justinblaber)\
**Post date:** [January 28, 2021, 1:42pm UTC](https://numba.discourse.group/t/jitclass-with-input-of-list-of-jitclass/475/3 "2021-01-28T13:42:00Z")

</div>

Yep, `foo.class_type.instance_type` works! Thanks!!!

---

<div class="post-metadata">

**Author:** ![Hannes](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/hannes/32/188_2.png) [@Hannes](https://numba.discourse.group/u/Hannes)\
**Post date:** [January 28, 2021, 2:43pm UTC](https://numba.discourse.group/t/jitclass-with-input-of-list-of-jitclass/475/4 "2021-01-28T14:43:19Z")

</div>

Great 🙂  
If that solves your problem you can mark the thread as answered
