Skip to content

mjdorma/prefixtree

 
 

Repository files navigation

prefixtree

This package implements dictionary and set like objects using prefix trees.

Tries

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.

Status

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.

PrefixDict

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.

PrefixSet

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.

Compatability

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

build_status

Continuous integration testing is provided by Travis CI.

Issues

Source code for prefixtree is hosted on GitHub. Please file bug reports with GitHub's issues system.

About

Python dictionary and set objects implemented using prefix trees

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published