Skip to content
项目

关于

基于 marisa-trie C++ 库、面向 Python 的静态节省内存的 Trie 类结构。

开发工具

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
-1
1个月
-2

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

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

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

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);
  • Trie, BytesTrie and RecordTrie provide 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 or BSD 2-clause license.

探索相关项目

加载中…