Static memory-efficient and fast Trie-like structures for Python.
Project description
MARISA Trie
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.
Installation
python -m pip install -U marisa-trie
Usage
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
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)
has_keys_with_prefix(prefix) method (thanks Matt Hickford)
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for marisa_trie-0.7.7-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37d121319813dbe9e9ff27f3a50ccff772d93296b27d6a8e32c08460827f477c |
|
MD5 | eb50a7d31b9f4ae86f5af946e1ca3923 |
|
BLAKE2b-256 | 2638fbccaf38ba4c3ceef4411a8f51ea07272699b504a18ec1dcbf76bb999e30 |
Hashes for marisa_trie-0.7.7-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2e25ec564f51d67e4406cdb52cba4942ebce07cb93b959ddadafbbdcd8523b1 |
|
MD5 | 04083cfd67a9e1437e16239ee7f69b6b |
|
BLAKE2b-256 | 09abb942458f28f85eb3ca6a8826f4cb94aba2c9a8c593449e4649840181b679 |
Hashes for marisa_trie-0.7.7-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 197b41decda4865b9d6e24f3c0eccebf5804c89d7bbe35c77fee45dba3989c8a |
|
MD5 | 24d88c6c376ec8da9bc370da8ce35c47 |
|
BLAKE2b-256 | 8a15372b7ee09fc2956bb90a60d5598ab1b158f98481012795f36f80f4556e96 |
Hashes for marisa_trie-0.7.7-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 939c14a81c466ebbc0985d1ac2b8f167c52add5231789359e9262d6558be731c |
|
MD5 | d227892c3794ecdd2df3e337268b65f2 |
|
BLAKE2b-256 | ad268291de2fa222e85d4b1fee6664b3507a21022d3792e78cb0734b13f889ea |
Hashes for marisa_trie-0.7.7-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65e9ae1c080587dffeec3dd2e7da88120ecb090e6cad2714a8da1a5a7e56ac4f |
|
MD5 | d6821ba2e514ac541dcc76aba6ff6ef2 |
|
BLAKE2b-256 | 06e53b1f4baef7dc6488a3c65abf4d2032a8f6eb6aca884a0c69b6a7e0d6be73 |
Hashes for marisa_trie-0.7.7-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a53632478f839d2d02450ca2108350d983eb61319bb8da4c63d5f8e660ee8a0 |
|
MD5 | 1863466345fda6fcff45afd43d147e53 |
|
BLAKE2b-256 | 653de4a17cba54c2688a490ddff4920d3081e523f9908b8548a2989998af5af7 |
Hashes for marisa_trie-0.7.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8863b9df15abd984d5faf11d129e626255468569ac2c7365519168d68f7dc7eb |
|
MD5 | 8ca54357fd4ad95e6536914583cf4d1d |
|
BLAKE2b-256 | 957ffb11ab6cb77ce68c079b370af01aa3635365ae8b8bb6749a05e92c9b0dea |
Hashes for marisa_trie-0.7.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1f51f814b81847eafc4b622188b453c9fae765ace812caf67da140a6d435f99 |
|
MD5 | bab1e49ab443dc17ee4ecc0b4ade3824 |
|
BLAKE2b-256 | dde0a4fe845626521ead7592ffd65645bf279fc8304d7dc0a8f9cc2f23c1282c |
Hashes for marisa_trie-0.7.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df23addeb641d3b6a80e4127a8f19074ebf1cbe9eb80206ee99e57da0f51e7f2 |
|
MD5 | cdea88adaad87c5019a31b4f90da5490 |
|
BLAKE2b-256 | e37605b294bf54f50e9fda14e01d9919c73f4b3ebf6c298154a97508d34ed97e |
Hashes for marisa_trie-0.7.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f86a718b4023904cf4a9e7ac1d967cb99b540ae05d081cf8b437129031f0845f |
|
MD5 | 360b5aaf0087d6886d996e4df7a1d29d |
|
BLAKE2b-256 | fd5dacaae41940937afc7a7ed416354845683ceacae4c9d9b7599033b7876e11 |
Hashes for marisa_trie-0.7.7-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7732907dfc1cf954d840cd95e4f63a52c61a9f6e864a3104e0427c4845fcfe82 |
|
MD5 | b24c757c8cf1ba5b8b5de226b8cb6228 |
|
BLAKE2b-256 | 43b6a7b365ef4342a99a1c67d73336286d0dcf901e3f38609e2ed6ae99a7b805 |
Hashes for marisa_trie-0.7.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2638e9abd05b9b3cf19adfb30ac503e7fb32247b8defa97c9a5f09fa8330063 |
|
MD5 | e623c6bc8d8d14ec5c3baeefbb25abfa |
|
BLAKE2b-256 | 62ce258e342d82a105196de9885aaf87cc3f28c4ca0ac13470d44ca026b75a6e |
Hashes for marisa_trie-0.7.7-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2540463270999718dc434d733e172b0918541fe123460494e19bcc185dbaefe |
|
MD5 | 3815902f1ec854efd975e8eddbf5e0ed |
|
BLAKE2b-256 | a7357aed3da3cacf461a65d66695cef747a6b15981791edbaf1f6dc57b449bb1 |
Hashes for marisa_trie-0.7.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 643fb52f6658ef9f77f66b736207acdd4d372272381a95b0ecdc20c98614f9ba |
|
MD5 | 770a677c55974862ec0e963093d8a7f5 |
|
BLAKE2b-256 | 4c89d837a3dde653381a51bd9c5e71a46825224c1d7a129da0f2b20eee2ece56 |
Hashes for marisa_trie-0.7.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16e9147753f2a211f9674e7b866bc931566950a6695d89b0d92bab8f6f34fe2b |
|
MD5 | c689e2a3d2613a0ad7d03f5c7532de6c |
|
BLAKE2b-256 | 04c67b369e841ab5a64c1264db2a61abc8569722526e336e1dc5f6c890299466 |
Hashes for marisa_trie-0.7.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ab818dcd557a6d673bc1f12e1f2dc69e62dacfe7ad444e723410aa745882210 |
|
MD5 | fdb1d253787ff72727bf08fe6d4f8e81 |
|
BLAKE2b-256 | 86eb81a86690cbc16a8b6629a849df800fadf7a985c0b1be0357b47635dbb754 |
Hashes for marisa_trie-0.7.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882ba0a90d961f93ec89b36c388dc0a6a7ffb871a6eb283a7a92485987212e22 |
|
MD5 | b23f15b07f21ec4cbb34769693564bb5 |
|
BLAKE2b-256 | 88af25f6d19c85e8ad1db8f121bdd71ce6a1b8a8bb6500be0aae8ad3427f087c |
Hashes for marisa_trie-0.7.7-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0614aadb611e11c48d8d4d5710827e5b3a944ebfb4c51a999bfdde133dc4e9b |
|
MD5 | f9b14477fdba34bbe1d39be0fe3f3b9d |
|
BLAKE2b-256 | b28da1eb65b2fc89f4ffea4c4088b06e72f7b486dff95be6f50ff3891ea35c1a |
Hashes for marisa_trie-0.7.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c978f7959218610780770725eb5bd88451e42f97af47ee220c1ae802fb9e402 |
|
MD5 | 5ec7dc23d5a20c28020f2106ab4ed158 |
|
BLAKE2b-256 | a88e7fa7ecfe83a01d003c81c62f92c9287934b5e8110eb9077ace53de2187bb |
Hashes for marisa_trie-0.7.7-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d6e3174d9e9ed73ae9934b0c8e9c630a19a3182dca508825f44e3e5a1641cd |
|
MD5 | c2968ecadb23a82bf85840ae84db106b |
|
BLAKE2b-256 | cb0a8f3ca5b8e57dd5e3910ea4db0b03c3e55436d12ad24b01b00bc2866f36b4 |
Hashes for marisa_trie-0.7.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a96100cc5cd6f50a1b02e20ece8dd05f476d1deb3062832259d87a6f4729ae4 |
|
MD5 | 98c7aaad7c8fc2fc37cada6fccf30ec6 |
|
BLAKE2b-256 | 57de5b828fb5631cab933c185a67d107777214b712f993b3cfa5cce75f83699d |
Hashes for marisa_trie-0.7.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df910508422ea2b331d2ce41a2c96f26f110663efb4c318525eedccd7b103af |
|
MD5 | 91d46ce0c9134700598bcbffca6c4e99 |
|
BLAKE2b-256 | 6ed847c9a299037910b86867965d0ab1e71e76940a6f2313dcf6e14920c6195d |
Hashes for marisa_trie-0.7.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09bf4b0e2df7f07e5a59e2e07b6aa9ee781d48be7509eba11087bc2a8e1a94ad |
|
MD5 | f991022afe92c3410031e40a420929c0 |
|
BLAKE2b-256 | ebba5843b0c815d87b4eaf7ccdf1580af85cdf42884c29ebd5f5c2d43be7f8de |
Hashes for marisa_trie-0.7.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ae6ef87610489f9b756916145550b99a1a87f672233111c20d7c9c91c3cf7b2 |
|
MD5 | 18ded8af8520e0f1e6dd3466d729205e |
|
BLAKE2b-256 | 9800a2b613feaaa5fe734ed87b55acf778f1f59f1a728555df80deb3d5f8ac55 |
Hashes for marisa_trie-0.7.7-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e060334862ba425568478fdbae2ec6599a6e123ac2b4c946b50f5e3417ed2072 |
|
MD5 | cbd296672a9fb313c820784353a2dd63 |
|
BLAKE2b-256 | b16c400972c08fe6c391fa16a690d1f29fdf9947a396705c90ba16d3b4d39cb5 |
Hashes for marisa_trie-0.7.7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 984ec658756a92d72e7bf664be02e6a1949a0e08658d5120e43fd26b9bd49187 |
|
MD5 | fa82ae90412f9d1a333cf43b7f5ca816 |
|
BLAKE2b-256 | 0f932df3f68297fd5ab8c70e8574a08c299bb84ba5bb1cfee2902e0712ee5170 |
Hashes for marisa_trie-0.7.7-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150bbc78b98135e9c43eee43ac548fe4393bd069213c5104555e5cc108df0546 |
|
MD5 | e70ad4a93a48859174cb9e435831ad69 |
|
BLAKE2b-256 | db50aa3fb4de432561b98701d6d1f46e674fd819b79e8924aaa626c7b3b068b6 |
Hashes for marisa_trie-0.7.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 332ca107795dd67f21aafbc0141252dc33d1f8f1b4239cc7bb61b67cae33cf30 |
|
MD5 | de773afebdac9e17baddba76aedd99a7 |
|
BLAKE2b-256 | 2d4d8a622a03ba1a0798667a737a6f3c703605092572cdbd254db0f25ac50a88 |
Hashes for marisa_trie-0.7.7-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55c99a3fd4025a5f428f83ba678912844014806f36684c8690deb59ca08c93af |
|
MD5 | dd2263546a1a7b39e43c04f1ef4ec683 |
|
BLAKE2b-256 | beb6c4ad9e629c5c5ae2675d4544df4aaddcd15622ced2ac81044d9b006ff82b |
Hashes for marisa_trie-0.7.7-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afa06ffe3a992de978582246550f3fe365cf3eaf0468b27e8cdf04ac2b5dbeeb |
|
MD5 | 0900182f97b9a0978d4ef68804145cca |
|
BLAKE2b-256 | 5fd466dab2aa986f820ba616c8c345f21dd8159027f51e957dc65073193acf28 |
Hashes for marisa_trie-0.7.7-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8db8e511e2d3b42221de0ed95ed6288ad514df0f7f88d0813990ea871ccd0baf |
|
MD5 | 50d2312ff9f4e22f1688c69c3984b8f0 |
|
BLAKE2b-256 | 8f8204bb1f49d2242406d580ac3fb7ccf3c7c75aebc53557ab53e9e3275a9d12 |
Hashes for marisa_trie-0.7.7-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64e76e9ed5c7b5929d9c598f343039f75ef4ae1881a8bb1b633d5fe624ae6b84 |
|
MD5 | 4ebc3182dfa5d8cf17db1cb7ca405f23 |
|
BLAKE2b-256 | e18e9087a55c68827255f66007fc728d04c283e161364b59026c7fa2a872395a |
Hashes for marisa_trie-0.7.7-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 739178a8f98d7584d5613c59a0346273d8a95154b0bcb0eb0bd11d6514a61dff |
|
MD5 | 80919d198b9e1e681475a41b2c315702 |
|
BLAKE2b-256 | b285da598cdb7e255a4a86eaf9819dc2b0d2d8e56ed6b67b5032a2aa418bfe60 |
Hashes for marisa_trie-0.7.7-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c77def45f1daf6bec70af9667092e9d45457f15032a75b0921239792891faf7 |
|
MD5 | 94f279887616961be022658aa823a02e |
|
BLAKE2b-256 | c6d2c796b9fbc468d13e0a382a7f2978d465d3046d6ad3873b20852f2348e86a |
Hashes for marisa_trie-0.7.7-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62ca721b1be9aa2be1157b386be5dd55c0f78a7b92a25390a6fa663ed47ed222 |
|
MD5 | 76a0b09568f10f07b80498d00fc92339 |
|
BLAKE2b-256 | 845c8b469875c567d299ed43ee0416ee242e8f0992561585409af0e16ce5e4a7 |