This package implements dictionary and set like objects using prefix trees.
Tries, also known as prefix trees, are an ordered tree data structure. Using a tries minimises the ammount of memory required to store keys the keys frequently share the same prefix.
In addition to minimising memory, tries are ordered. This allows prefix tree based dicitonaries and sets to support slicing operations.
prefixtree is still in an early stage of development, the trove classifier has for development status has been set to "Pre-Alpha". The most significant feature missing is the support for slices. Currently the only feature expoiting the trie is the startswith() method.
This dictionary like object, implemented using a trie, is an implementation of the MutableMapping abstract base class. :
>>> from prefixtree import PrefixDict
>>> pd = PrefixDict()
>>> pd['abc'] = Ellipsis
>>> 'abc' in pd
True
PrefixDict supports the same construction methods as the builtin dict object.
This set like object, implemented using a trie, is an implementation of the MutableSet abstract base class. :
>>> from prefixtree import PrefixSet
>>> ps = PrefixSet()
>>> ps.add('abc')
>>> 'abc' in pd
True
PrefixSet supports the same construction methods as the builtin set object.
prefixtree is implemented to be compatible with Python 2.7 and Python 3.2. It has been tested against the following Python implementations:
- CPython 2.7
- CPython 3.2
- PyPy 1.9.0
Continuous integration testing is provided by Travis CI.
Source code for prefixtree is hosted on GitHub. Please file bug reports with GitHub's issues system.