Static memory-efficient Trie-like structures for Python (2.7 and 3.4+) based on marisa-trie C++ library.
String data in a MARISA-trie may take up to 50x-100x less memory than in a standard Python dict; the raw lookup speed is comparable; trie also provides fast advanced methods like prefix search.
There are official SWIG-based Python bindings included in C++ library distribution; this package provides alternative Cython-based pip-installable Python bindings.
pip install marisa-trie
- The library is not tested with mingw32 compiler;
RecordTrieis quite slow and doesn't have iterator counterpart;
write()methods don't work with file-like objects (they work only with real files; pickling works fine for file-like objects);
- there are
items()methods but no
Wrapper code is licensed under MIT License.
Bundled marisa-trie C++ library is dual-licensed under LGPL and BSD 2-clause license.