Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict type in nopython mode #2096

Closed
seibert opened this issue Sep 3, 2016 · 17 comments
Closed

Dict type in nopython mode #2096

seibert opened this issue Sep 3, 2016 · 17 comments

Comments

@seibert
Copy link
Contributor

seibert commented Sep 3, 2016

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

@fabioz
Copy link

fabioz commented Oct 26, 2016

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).

@carlosvega
Copy link

This feature would be awesome.

@garyrob
Copy link

garyrob commented Sep 28, 2017

+1.

@synapticarbors
Copy link
Contributor

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.

@garyrob
Copy link

garyrob commented Oct 11, 2017

Very nice interim measure! Thanks!

@tamasgal
Copy link

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!

@hameerabbasi
Copy link
Contributor

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.

@ericmjl
Copy link

ericmjl commented Dec 20, 2018

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.

@tamasgal
Copy link

@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.

@seibert
Copy link
Contributor Author

seibert commented Dec 20, 2018

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

@ericmjl
Copy link

ericmjl commented Dec 20, 2018

@seibert thank you for letting us know! 😄 🎉

@caiofcm
Copy link

caiofcm commented Mar 13, 2019

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

@stuartarchibald
Copy link
Contributor

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

@sklam
Copy link
Member

sklam commented Mar 14, 2019

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

@sklam sklam closed this as completed Mar 14, 2019
@ericmjl
Copy link

ericmjl commented Mar 14, 2019

👍 😄 😸 !

@Avik1993
Copy link

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

@stuartarchibald
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests