Skip to main content

Static memory-efficient and fast Trie-like structures for Python.

Project description

MARISA Trie

https://img.shields.io/pypi/pyversions/marisa-trie.svg https://github.com/pytries/marisa-trie/actions/workflows/tests.yml/badge.svg

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

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.

CHANGES

1.1.0 (2023-10-06)

  • Added Python 3.12 support.

1.0.0 (2023-09-03)

  • Dropped Python 2.7, 3.4, 3.5, 3.6 support.

  • Added Trie.map() (#90).

  • Rebuilt Cython wrapper with Cython 3.0.2.

  • Fixed benchmark documentation typos (#89).

0.8.0 (2023-03-25)

  • Add Trie.iter_prefixes_with_ids() method to return (prefix, id) pairs (#83).

  • Rebuild Cython wrapper with Cython 0.29.33 (#88).

0.7.8 (2022-10-25)

  • Added Python 3.11 support.

  • Rebuild Cython wrapper with Cython 0.29.32.

0.7.7 (2021-08-04)

  • Restored Python 2.7 support.

  • Fixed README image references not working on Windows.

0.7.6 (2021-07-28)

  • Wheels are now published for all platforms.

  • Fixed ResourceWarning: unclosed file in setup.py.

  • Run black on the entire source code.

  • Moved the QA/CI to GitHub.

  • Rebuild Cython wrapper with Cython 0.29.24.

  • Updated libmarisa-trie to the latest version (0.2.6).

  • Fixed failing tests and usage of deprecated methods.

  • Expanded supported Python version (2.7, 3.4 - 3.10).

0.7.5 (2018-04-10)

  • Removed redundant DeprecationWarning messages in Trie.save and Trie.load.

  • Dropped support for Python 2.6.

  • Rebuild Cython wrapper with Cython 0.28.1.

0.7.4 (2017-03-27)

  • Fixed packaging issue, MANIFEST.in was not updated after libmarisa-trie became a submodule.

0.7.3 (2017-02-14)

  • Added BinaryTrie for storing arbitrary sequences of bytes, e.g. IP addresses (thanks Tomasz Melcer);

  • Deprecated Trie.has_keys_with_prefix which can be trivially implemented in terms of Trie.iterkeys;

  • Deprecated Trie.read and Trie.write which onlywork for “real” files and duplicate the functionality of load and save. See issue #31 on GitHub;

  • Updated libmarisa-trie to the latest version. Yay, 64-bit Windows support.

  • Rebuilt Cython wrapper with Cython 0.25.2.

0.7.2 (2015-04-21)

  • packaging issue is fixed.

0.7.1 (2015-04-21)

  • setup.py is switched to setuptools;

  • a tiny speedup;

  • wrapper is rebuilt with Cython 0.22.

0.7 (2014-12-15)

  • trie1 == trie2 and trie1 != trie2 now work (thanks Sergei Lebedev);

  • for key in trie: is fixed (thanks Sergei Lebedev);

  • wrapper is rebuilt with Cython 0.21.1 (thanks Sergei Lebedev);

  • https://bitbucket.org/kmike/marisa-trie repo is no longer supported.

0.6 (2014-02-22)

  • New Trie methods: __getitem__, get, items, iteritems. trie[u'key'] is now the same as trie.key_id(u'key').

  • small optimization for BytesTrie.get.

  • wrapper is rebuilt with Cython 0.20.1.

0.5.3 (2014-02-08)

  • small Trie.restore_key optimization (it should work 5-15% faster)

0.5.2 (2014-02-08)

  • fix Trie.restore_key method - it was reading past declared string length;

  • rebuild wrapper with Cython 0.20.

0.5.1 (2013-10-03)

0.5 (2013-05-07)

  • BytesTrie.iterkeys, BytesTrie.iteritems, RecordTrie.iterkeys and RecordTrie.iteritems methods;

  • wrapper is rebuilt with Cython 0.19;

  • value_separator parameter for BytesTrie and RecordTrie.

0.4 (2013-02-28)

  • improved trie building: weights optional parameter;

  • improved trie building: unnecessary input sorting is removed;

  • wrapper is rebuilt with Cython 0.18;

  • bundled marisa-trie C++ library is updated to svn r133.

0.3.8 (2013-01-03)

  • Rebuild wrapper with Cython pre-0.18;

  • update benchmarks.

0.3.7 (2012-09-21)

  • Update bundled marisa-trie C++ library (this may fix more mingw issues);

  • Python 3.3 support is back.

0.3.6 (2012-09-05)

  • much faster (3x-7x) .items() and .keys() methods for all tries; faster (up to 3x) .prefixes() method for Trie.

0.3.5 (2012-08-30)

  • Pickling of RecordTrie is fixed (thanks lazarou for the report);

  • error messages should become more useful.

0.3.4 (2012-08-29)

  • Issues with mingw32 should be resolved (thanks Susumu Yata).

0.3.3 (2012-08-27)

  • .get(key, default=None) method for BytesTrie and RecordTrie;

  • small README improvements.

0.3.2 (2012-08-26)

  • Small code cleanup;

  • load, read and mmap methods returns ‘self’;

  • I can’t run tests (via tox) under Python 3.3 so it is removed from supported versions for now.

0.3.1 (2012-08-23)

  • .prefixes() support for RecordTrie and BytesTrie.

0.3 (2012-08-23)

  • RecordTrie and BytesTrie are introduced;

  • IntTrie class is removed (probably temporary?);

  • dumps/loads methods are renamed to tobytes/frombytes;

  • benchmark & tests improvements;

  • support for MARISA-trie config options is added.

0.2 (2012-08-19)

  • Pickling/unpickling support;

  • dumps/loads methods;

  • python 3.3 workaround;

  • improved tests;

  • benchmarks.

0.1 (2012-08-17)

Initial release.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marisa-trie-1.1.0.tar.gz (410.6 kB view hashes)

Uploaded Source

Built Distributions

marisa_trie-1.1.0-pp310-pypy310_pp73-win_amd64.whl (142.1 kB view hashes)

Uploaded PyPy Windows x86-64

marisa_trie-1.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (185.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (189.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (161.6 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

marisa_trie-1.1.0-pp39-pypy39_pp73-win_amd64.whl (141.8 kB view hashes)

Uploaded PyPy Windows x86-64

marisa_trie-1.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (184.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (188.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (161.3 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

marisa_trie-1.1.0-pp38-pypy38_pp73-win_amd64.whl (139.7 kB view hashes)

Uploaded PyPy Windows x86-64

marisa_trie-1.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (182.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (186.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (159.8 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

marisa_trie-1.1.0-pp37-pypy37_pp73-win_amd64.whl (139.7 kB view hashes)

Uploaded PyPy Windows x86-64

marisa_trie-1.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (184.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (188.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (159.7 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

marisa_trie-1.1.0-cp312-cp312-win_amd64.whl (150.9 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

marisa_trie-1.1.0-cp312-cp312-win32.whl (130.0 kB view hashes)

Uploaded CPython 3.12 Windows x86

marisa_trie-1.1.0-cp312-cp312-musllinux_1_1_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

marisa_trie-1.1.0-cp312-cp312-musllinux_1_1_i686.whl (1.9 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ i686

marisa_trie-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-cp312-cp312-macosx_11_0_arm64.whl (182.3 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

marisa_trie-1.1.0-cp312-cp312-macosx_10_9_x86_64.whl (198.0 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

marisa_trie-1.1.0-cp312-cp312-macosx_10_9_universal2.whl (375.3 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)

marisa_trie-1.1.0-cp311-cp311-win_amd64.whl (152.6 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

marisa_trie-1.1.0-cp311-cp311-win32.whl (131.4 kB view hashes)

Uploaded CPython 3.11 Windows x86

marisa_trie-1.1.0-cp311-cp311-musllinux_1_1_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

marisa_trie-1.1.0-cp311-cp311-musllinux_1_1_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

marisa_trie-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-cp311-cp311-macosx_11_0_arm64.whl (184.7 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

marisa_trie-1.1.0-cp311-cp311-macosx_10_9_x86_64.whl (201.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

marisa_trie-1.1.0-cp311-cp311-macosx_10_9_universal2.whl (381.7 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

marisa_trie-1.1.0-cp310-cp310-win_amd64.whl (152.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

marisa_trie-1.1.0-cp310-cp310-win32.whl (131.3 kB view hashes)

Uploaded CPython 3.10 Windows x86

marisa_trie-1.1.0-cp310-cp310-musllinux_1_1_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

marisa_trie-1.1.0-cp310-cp310-musllinux_1_1_i686.whl (1.9 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

marisa_trie-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-cp310-cp310-macosx_11_0_arm64.whl (183.5 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

marisa_trie-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl (200.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

marisa_trie-1.1.0-cp310-cp310-macosx_10_9_universal2.whl (379.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

marisa_trie-1.1.0-cp39-cp39-win_amd64.whl (152.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

marisa_trie-1.1.0-cp39-cp39-win32.whl (131.2 kB view hashes)

Uploaded CPython 3.9 Windows x86

marisa_trie-1.1.0-cp39-cp39-musllinux_1_1_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

marisa_trie-1.1.0-cp39-cp39-musllinux_1_1_i686.whl (1.9 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

marisa_trie-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-cp39-cp39-macosx_11_0_arm64.whl (184.1 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

marisa_trie-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl (201.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

marisa_trie-1.1.0-cp39-cp39-macosx_10_9_universal2.whl (380.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

marisa_trie-1.1.0-cp38-cp38-win_amd64.whl (152.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

marisa_trie-1.1.0-cp38-cp38-win32.whl (131.3 kB view hashes)

Uploaded CPython 3.8 Windows x86

marisa_trie-1.1.0-cp38-cp38-musllinux_1_1_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

marisa_trie-1.1.0-cp38-cp38-musllinux_1_1_i686.whl (1.9 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

marisa_trie-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-cp38-cp38-macosx_11_0_arm64.whl (184.1 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

marisa_trie-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl (201.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

marisa_trie-1.1.0-cp38-cp38-macosx_10_9_universal2.whl (380.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

marisa_trie-1.1.0-cp37-cp37m-win_amd64.whl (151.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

marisa_trie-1.1.0-cp37-cp37m-win32.whl (130.2 kB view hashes)

Uploaded CPython 3.7m Windows x86

marisa_trie-1.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl (1.9 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

marisa_trie-1.1.0-cp37-cp37m-musllinux_1_1_i686.whl (1.8 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

marisa_trie-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

marisa_trie-1.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (1.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

marisa_trie-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (198.1 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page