Python dictionary with constant type value

I came across a case where I need a large (= huge) python dictionary, which turned out to be quite multi-user. However, since all values ​​are of the same type (long), as well as keys, I decided that I could use a python array (or numpy, it does not matter) for the values; and wrap the necessary interface (in: x; out: d [x]) with the object that actually uses these arrays to store keys and values.

I can use the index conversion object (input β†’ index, 1..n, where n is the counter of different values) and return the [index] array. I can tell you in detail about some methods of implementing such indexing methods with a reasonable memory requirement, it works and is even very good. However, I wonder if such a data structure object already exists (in python or wrapped in python from C / ++), in any package (I checked the collections and some google searches).

Any comments would be welcome, thanks.

+3
source share
2 answers

( ). . , sqlite3 .

, Python ( array ); , - . bisect.bisect.

+2

std:: map. Boost.Python Python- std:: map .

0

Source: https://habr.com/ru/post/1747814/


All Articles