Skip to content

Static memory-efficient Trie-like structures for Python based on marisa-trie C++ library.

License

Notifications You must be signed in to change notification settings

pytries/marisa-trie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

446baad · Mar 27, 2025
Feb 23, 2025
Oct 18, 2024
Aug 30, 2023
Feb 23, 2025
Jul 27, 2021
Feb 11, 2025
Aug 31, 2023
Oct 5, 2022
Sep 2, 2016
Jul 27, 2021
Feb 23, 2025
Jan 1, 2025
Jul 28, 2021
Mar 27, 2025
Feb 23, 2025
Aug 30, 2023

Repository files navigation

MARISA Trie

PyPI Version PyPI Status PyPI Python Versions Github Build Status

Tip

Become my boss to help me work on this awesome software, and make the world better:

Patreon

Static memory-efficient Trie-like structures for Python (3.8+) 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.

Note

There are official SWIG-based Python bindings included in C++ library distribution; this package provides alternative Cython-based pip-installable Python bindings.

Installation

python -m pip install -U marisa-trie

Usage

See tutorial and API for details.

Current limitations

  • The library is not tested with mingw32 compiler;
  • .prefixes() method of BytesTrie and RecordTrie is quite slow and doesn't have iterator counterpart;
  • read() and write() methods don't work with file-like objects (they work only with real files; pickling works fine for file-like objects);
  • there are keys() and items() methods but no values() method.

License

Wrapper code is licensed under MIT License.

Bundled marisa-trie C++ library is dual-licensed under LGPL and BSD 2-clause license.