Fast and simple SumTree implementation in Rust with Python bindings
Project description
SumTree
This module contains a SumTree implementation in Rust with Python wrappers. Speedup is around 10x in comparison to an equivalent full Python implementation.
Check the project on github: https://github.com/yamoling/sumtree
Usage
Initialisation
from sumtree import SumTree
st = SumTree(1024)
st.add(10)
print(st.total) # 10
print(len(st)) # 1
print(st.capacity) # 1024
Sampling data
from sumtree import SumTree
st = SumTree(1024)
for i in range(1024):
st.add(i)
index, value = st.get(500)
print(index, value) # 32, 32.0
indices, values = st.sample(10)
Updating data
from sumtree import SumTree
st = SumTree(1024)
for i in range(1024):
st.add(i)
# Set leaf 0 to value 40.
tree.update(0, 40.)
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
sumtree-0.2.8.tar.gz
(21.8 kB
view details)
File details
Details for the file sumtree-0.2.8.tar.gz.
File metadata
- Download URL: sumtree-0.2.8.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be6a722ff8072358c5a93bf4ac4f294c46396e0a76ddffbc5190bb23d3d7a050
|
|
| MD5 |
1e77fc5770910680bffceaf4d5a6a6b5
|
|
| BLAKE2b-256 |
7af67fbb45072c9b6c9e682c83457260dc952458cf549ff32d65ce5aafc5cced
|