Numba: Dict type in nopython mode

Created on 3 Sep 2016  路  17Comments  路  Source: numba/numba

Hash tables are very useful, and would be nice in nopython mode.

Numba1.0 highpriority

Most helpful comment

Dictionary support is on our roadmap (just being reviewed now in #3617) for first half of 2019.

All 17 comments

Just wanted to say that this would be really nice (I have some code right now which could be made considerably faster if there was some API I could use for caching to skip some computation -- I even tried creating an int->int hashtable for my use case and couldn't really find a good way to do it in nopython mode as it's not possible to create something as [[(int, int)]]) for the buckets).

This feature would be awesome.

+1.

While I would also love support for typed dicts in nopython mode, I threw together this proof-of-concept using khash (which pandas uses under-the-hood) and cffi to get a int->int hashmap that is callable in nopython mode:

https://github.com/synapticarbors/khash_numba

Maybe this will be useful to some people in the interim. Depending on the number of unique elements that are being mapped, it looks like it is often faster to use a numpy array (trading speed for increased memory consumption), but there are definitely cases where this solution looks to be better.

Very nice interim measure! Thanks!

Is there any news on this? I have tons of lookup tables which I want to use in my jitted functions... This features would be huge!

We just ran into needing this for our custom-rolled DOK implementation over in pydata/sparse#126. It'd be a big help if it was added.

I would also like to register my vote for dictionary support in Numba.

My use case is as follows: I have been writing graph neural network models using numpy + autograd, and I would like to be able to see JIT compilation of my for-loop intensive code. (Long story cut short, I am looping over pairs of matrices to get around an inability to use block sparse matrices with autograd.)

The parameters that I optimize are stored in a dictionary, so that I can access them by name in each function layer of the neural network.

@ericmjl meanwhile you can try the Julia language (sorry for advertising) ;) It's JIT, python-like syntax and C-speed. Talks to Python without significant overhead.

Dictionary support is on our roadmap (just being reviewed now in #3617) for first half of 2019.

@seibert thank you for letting us know! :smile: 馃帀

Cool, included in 0.43 as experimental feature :tada:, thank you!
https://numba.pydata.org/numba-doc/dev/reference/pysupported.html#dict

@sklam think you should have the honour of closing this :)

Closing this. We now have a typed dictionary since 0.43.

:+1: :smile: 馃樃 !

This is so cool. However, is there anyway I can get around nested dictionaries?

This is so cool. However, is there anyway I can get around nested dictionaries?

@Avik1993 Please could you clarify what you mean and open a new issue with an example of what you want to do but does not work at present, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

devxpy picture devxpy  路  3Comments

hippke picture hippke  路  4Comments

hameerabbasi picture hameerabbasi  路  3Comments

mroeschke picture mroeschke  路  3Comments

elfnor picture elfnor  路  4Comments