Skip to main content

Adaptive Radix Tree (ART) implemetation for python.

Project description

Travis badge Bitdeli badge

This library is a thin python wrapper around ART implementation in


pystat can be installed via pypi:

pip install pyart


Get the source:

git clone

Compile extension:

python build_ext --inplace


Work with tree as with plain mapping:

from pyart import Tree
t = Tree()
t[b'foo'] = 1
t[b'bar'] = 2
assert t[b'foo'] == 1
assert t[b'bar'] == 2
assert b'foo' in t
assert b'bar' in t
assert len(t) == 2
del t[b'foo']
assert b'foo' not in t
assert len(t) == 1

Iteration over each element of tree:

from pyart import Tree
t = Tree()
t['foo'] = object()
def cb(key, value): print(key, value)
>>> ('foo', <object object at 0x7f186020bd70>)
t['foobar'] = object()
>>> ('foo', <object object at 0x7f186020bd70>)
>>> ('foobar', <object object at 0x7f186020bd80>)
t.each(cb, prefix=b'foo')
>>> ('foo', <object object at 0x7f186020bd70>)
>>> ('foobar', <object object at 0x7f186020bd80>)
t.each(cb, prefix=b'bar')

Find minimum and maximum:

from pyart import Tree
t = Tree()
t[b'test'] = None
t[b'foo'] = None
t[b'bar'] = None
assert t.minimum == (b'bar', None)
assert t.maximum == (b'test', None)

Copy tree:

from pyart import Tree
t = Tree()
t[b'test'] = object()
c = t.copy()
assert c[b'test'] is t[b'test']
assert len(c) == len(t)


  • Implement plain python iterator over tree;

Running the test suite

Use Tox to run the test suite:




  • Fix reference counting;


  • Fix iteration with single element;


  • Fix segmentation fault on iterator destruction;


  • Proper exception handling in each;
  • Support for python native iteration;

0.1.0 (initial release)

  • Prototype.

Project details

Download files

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

Files for pyart, version 0.2.3
Filename, size File type Python version Upload date Hashes
Filename, size pyart-0.2.3.tar.gz (47.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page