Skip to main content

Pure python implementation of avl trees.

Project description

pyavl3

A python dictionary alternative implemented with an AVL Tree.

Quick Start

pip install pyavl3
from pyavl3 import AVLTree

a = AVLTree()
a[1] = "Hello"
a[2] = "world!"

print(", ".join(a.values()))

Why?

Python dictionaries are implemented on hashmaps. Hashmaps, besides being awesome, are a balancing act between efficiency and memory utilization. Python's builtin algorithm is solid and probably the correct choice 99 times out 100. Not really a supprise. But, hashmaps suffers from the need to resize and resizing is pretty expensive. For those few cases where resizing large in-memory blocks of sequentional memory is not going to work, AVLTrees might be a better option. Oh, and AVLTrees are effectivly sorted. So, iterators are deterministic and always in order.

This table compairs the runtime characteristics of Hashtables and AVLTrees

Hashtable Hashtable(worst case) AVLTree AVLTree(worst case)
Space O(n) O(n) O(n) O(n)
Search O(1) O(n) O(logn) O(logn)
Insert O(1) O(n) O(logn) O(logn)
Delete O(1) O(n) O(logn) O(logn)
Resize O(n) O(n) N/A N/A

Project details


Download files

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

Source Distribution

pyavl3-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyavl3-1.0.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pyavl3-1.0.0.tar.gz.

File metadata

  • Download URL: pyavl3-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

File hashes

Hashes for pyavl3-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e3532746585d2ed997619bdea9e616bd9b449ad12f663dc4092d10f3e3d4901d
MD5 84100c3d44fabd3cd9d6feb4b11f6909
BLAKE2b-256 cbf9a48abd1e59f7db5ec6a07615914bbfe87f21a2bc165d61217c1ce859d087

See more details on using hashes here.

File details

Details for the file pyavl3-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyavl3-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9

File hashes

Hashes for pyavl3-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a56c98839b8141757eea42bdcc2bf9ff8c6299065bb51505e96f063365035659
MD5 6c14ab5c17df9561145f9124c82fa0ea
BLAKE2b-256 779096485005bae96e423f019ce09198402813d76c40e44f0dd8384b8a7b4080

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page