marisa-trie README

The project's README from github.com/pytries/marisa-trie. As one markdown file: README.md.

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

.. _marisa-trie: https://github.com/s-yata/marisa-trie

Installation

::

python -m pip install -U marisa-trie

Usage

See tutorial_ and API_ for details.

For immutable str -> str mappings, use marisa_trie.StringTrie (implemented as two internal tries plus a compact ID mapping table).

.. _tutorial: https://marisa-trie.readthedocs.io/en/latest/tutorial.html .. _API: https://marisa-trie.readthedocs.io/en/latest/api.html

Current limitations

License

Wrapper code is licensed under MIT License.

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

.. |PyPI Version| image:: https://img.shields.io/pypi/v/marisa-trie.svg :target: https://pypi.python.org/pypi/marisa-trie/ .. |PyPI Status| image:: https://img.shields.io/pypi/status/marisa-trie.svg :target: https://pypi.python.org/pypi/marisa-trie/ .. |PyPI Python Versions| image:: https://img.shields.io/pypi/pyversions/marisa-trie.svg :target: https://pypi.python.org/pypi/marisa-trie/ .. |Github Build Status| image:: https://github.com/pytries/marisa-trie/actions/workflows/tests.yml/badge.svg :target: https://github.com/pytries/marisa-trie/actions/workflows/tests.yml .. |Patreon| image:: https://img.shields.io/badge/Patreon-F96854?style=for-the-badge&logo=patreon&logoColor=white :target: https://www.patreon.com/mschoentgen

marisa-trie (pytries/marisa-trie)

Searching Database…

What is this?Static, memory-efficient trie-like data structures for Python, built on the marisa-trie C++ library. Strings stored inside can take up to 50x-100x less memory than in a standard Python dict, with comparable lookup speed and fast prefix search.
Is this a library I add to my Python project, or a separate tool?A pip-installable library you import into Python code. It provides Cython-based bindings as an alternative to the official SWIG bindings that ship with the C++ library distribution.
Which Python versions does it support?Python 3.9 or newer; the GitHub topics also list PyPy3 support.
What are the current limitations?read() and write() only work with real files, not file-like objects — use pickling there instead. The .prefixes() method of BytesTrie and RecordTrie is quite slow with no iterator counterpart, and the trie classes expose keys() and items() but no values(). Mingw32 builds are also untested.
Is the license straightforward for commercial use?Mostly: the wrapper code is MIT-licensed, but the bundled marisa-trie C++ library is dual-licensed under LGPL or BSD 2-clause, so check the LGPL terms if you redistribute the C++ part.
What kinds of tries does the package provide?The main documented class is StringTrie for immutable str-to-str mappings, implemented as two internal tries plus a compact ID mapping table. Trie, BytesTrie and RecordTrie classes are also available.
The structures are described as 'static' — does that mean read-only?Yes — you build the trie once and then only query it. StringTrie is explicitly for immutable str-to-str mappings, so you trade updatability for the compact memory footprint and fast lookups.
What is MARISA?It is the C++ library underneath this package: marisa-trie implements the compact trie structures and memory layout, while this repo adds the Cython-based Python bindings and publishes them on PyPI.
Creator
pytries
Size
3.2 MB
Stars
1.1K
Age
14y
Commits · 90 Days