Data Structures Library
A comprehensive, zero-dependency collection of fundamental data structures for Python. The package is designed to be production-ready, strongly typed, and easy to use.
Installation
pip install data-structures-lib
Quick Start
from data_structures_lib import DynamicArray, HashMap, MinHeap, Trie, LRUCache
arr = DynamicArray()
arr.append(10)
arr.append(20)
print(arr[0]) # 10
m = HashMap()
m['name'] = 'Alice'
print(m['name']) # Alice
heap = MinHeap()
heap.push(5)
heap.push(1)
print(heap.pop()) # 1
t = Trie()
t.insert('cat')
t.insert('car')
print(t.starts_with('ca')) # True
cache = LRUCache(capacity=2)
cache['a'] = 1
cache['b'] = 2
cache['c'] = 3 # evicts 'a'
print('a' in cache) # False
Features
- Zero runtime dependencies: No external packages required
- Comprehensive coverage: Linear, hashing, trees, heaps, tries, graphs, caches, and probabilistic structures
- Type safe: Includes
py.typedmarker for type checkers - Well tested: Full test coverage for normal use, edge cases, and invalid operations
- Clear error messages: Explicit, helpful exceptions
Supported Data Structures
Linear
DynamicArray: automatically resizing arraySinglyLinkedList,DoublyLinkedList,CircularLinkedList: linked listsStack: LIFO stackQueue: FIFO queue
Hashing
HashMap: separate-chaining hash mapHashSet: separate-chaining hash set
Trees
BinarySearchTree: standard binary search treeAVLTree: self-balancing AVL tree
Heaps
MinHeap,MaxHeap: binary heaps
Others
Trie: prefix treeAdjacencyListGraph,AdjacencyMatrixGraph: graph representationsLRUCache: least-recently-used cacheBloomFilter: probabilistic membership filter
Usage Examples
Binary Search Tree
from data_structures_lib import BinarySearchTree
tree = BinarySearchTree()
for value in [5, 3, 7, 1, 4]:
tree.insert(value)
print(tree.search(4)) # True
AVL Tree
from data_structures_lib import AVLTree
tree = AVLTree()
for value in [10, 20, 30, 40, 50]:
tree.insert(value)
print(tree.height()) # small balanced height
Graph
from data_structures_lib import AdjacencyListGraph
g = AdjacencyListGraph()
g.add_edge('a', 'b')
g.add_edge('a', 'c')
print(g.bfs('a')) # ['a', 'b', 'c']
Bloom Filter
from data_structures_lib import BloomFilter
bf = BloomFilter(expected_items=1000, false_positive_rate=0.01)
bf.add('hello')
print(bf.has('hello')) # True
print(bf.has('world')) # probably False
Development
pip install -e ".[dev]"
pytest test_data_structures_lib.py -v
License
MIT License. See LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
data_structures_lib-1.1.0.tar.gz
(13.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file data_structures_lib-1.1.0.tar.gz.
File metadata
- Download URL: data_structures_lib-1.1.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2707bbf1d3b433a570062acd5bf6bdc4d72224b8b279f32b84b64d7fb1d75b2
|
|
| MD5 |
b7ce6a5b456faf9cc031b838b3a4cb32
|
|
| BLAKE2b-256 |
a97dc36597c6e7c52397e7c2ed5d0c2e721c8700484d9f052380e81600dac174
|
File details
Details for the file data_structures_lib-1.1.0-py3-none-any.whl.
File metadata
- Download URL: data_structures_lib-1.1.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19bb9d3e60f854bdbb112a6426d7ff65ee087ac3ca028b138f3a7be2ce240f12
|
|
| MD5 |
07723f5de62ebdc606f90466aeef0ba7
|
|
| BLAKE2b-256 |
20ea9444a49bbefd730cf4937678693345a4d4d966b698e1fa476f999e58b84d
|