# Nest dict with jit class

**URL:** <https://numba.discourse.group/t/nest-dict-with-jit-class/203>\
**Category:** Community Support\
**Created:** [August 31, 2020, 9:45am UTC](https://numba.discourse.group/t/nest-dict-with-jit-class/203 "2020-08-31T09:45:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubick1896](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@rubick1896](https://numba.discourse.group/u/rubick1896)\
**Post date:** [August 31, 2020, 9:45am UTC](https://numba.discourse.group/t/nest-dict-with-jit-class/203/1 "2020-08-31T09:45:15Z")

</div>

I am trying to use the jitclass function where one of my attributes is a nested dictionary.  
Here is my code.

@jitclass([(‘dt’, types.int32),  
(‘last\_index\_tick’, types.DictType(types.int32, types.DictType(types.unicode\_type, types.int64)))])  
class TickFeature:  
def **init** (self, dt: int):  
self.dt = dt  
#self.last\_index\_tick = defaultdict(dict)  
self.last\_index\_tick = numba.typed.Dict.empty(  
key\_type=types.int32,  
value\_type=types.DictType(types.unicode\_type, types.int64)  
)  
self.init\_index\_tick()

```
def init_index_tick(self, ):
    l = np.array([905, 300, 16, 399005, 399006], dtype=np.int64)

    tmp = numba.typed.Dict.empty(key_type=types.unicode_type, value_type=types.int64)
    '''
    self.last_index_tick = numba.typed.Dict.empty(
        key_type=types.types.int32,
        value_type=types.DictType(types.unicode_type, types.int64)
    )
    '''
    for item in l:
        self.last_index_tick[item] = tmp

```

Here is the error message.

Failed in nopython mode pipeline (step: nopython frontend)  
Failed in nopython mode pipeline (step: nopython frontend)  
No implementation of function Function(\<class ‘numba.core.types.containers.DictType’\>) found for signature:

> > > DictType(typeref[unicode\_type], class(int64))

There are 2 candidate implementations:  
- Of which 2 did not match due to:  
Overload in function ‘DictType’: File: numba/core/extending.py: Line 37.  
With argument(s): ‘(typeref[unicode\_type], class(int64))’:  
Rejected as the implementation raised a specific error:  
TypeError: typer() takes 0 positional arguments but 2 were given  
raised from /home/wenrui29/.opt/anaconda/lib/python3.7/site-packages/numba/core/typing/templates.py:363

During: resolving callee type: Function(\<class ‘numba.core.types.containers.DictType’\>)  
During: typing of call at (9)

File “”, line 9:  
def **init** (self, dt: int):  
  
key\_type=types.int32,  
value\_type=types.DictType(types.unicode\_type, types.int64)  
^

During: resolving callee type: jitclass.TickFeature#7fb898862590dt:int32,last\_index\_tick:DictType[int32,DictType[unicode\_type,int64]]  
During: typing of call at (3)

During: resolving callee type: jitclass.TickFeature#7fb898862590dt:int32,last\_index\_tick:DictType[int32,DictType[unicode\_type,int64]]  
During: typing of call at (3)

File “”, line 3:

---

<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:** [September 2, 2020, 8:40am UTC](https://numba.discourse.group/t/nest-dict-with-jit-class/203/2 "2020-09-02T08:40:18Z")

</div>

In case anyone else has this issue, it is answered here: [https://github.com/numba/numba/issues/6191#issuecomment-684022879](https://github.com/numba/numba/issues/6191#issuecomment-684022879)
