Skip to main content

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.typed marker 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 array
  • SinglyLinkedList, DoublyLinkedList, CircularLinkedList: linked lists
  • Stack: LIFO stack
  • Queue: FIFO queue

Hashing

  • HashMap: separate-chaining hash map
  • HashSet: separate-chaining hash set

Trees

  • BinarySearchTree: standard binary search tree
  • AVLTree: self-balancing AVL tree

Heaps

  • MinHeap, MaxHeap: binary heaps

Others

  • Trie: prefix tree
  • AdjacencyListGraph, AdjacencyMatrixGraph: graph representations
  • LRUCache: least-recently-used cache
  • BloomFilter: 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.0.1.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

data_structures_lib-1.0.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file data_structures_lib-1.0.1.tar.gz.

File metadata

  • Download URL: data_structures_lib-1.0.1.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for data_structures_lib-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5fd7674fc0522270aa344572bae433b42c4be43bef20bc6b63101248328c8e00
MD5 96452cdbdaa4131fec15d06e6864e615
BLAKE2b-256 325a217e6ea6f5c8371579ca3079951edafa71485ba339d05e613f1b93bdccea

See more details on using hashes here.

File details

Details for the file data_structures_lib-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for data_structures_lib-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6c1c7966ad4eb094a2d8a54812877b98dcf1fa1242fd363f2908901788c518d
MD5 bdcc5b76878dfaf00be0ac12004505af
BLAKE2b-256 631d3862454cd6e4a8469f8821ee0a1725a2336e452d57d3632f0499669ed48a

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.0

2 files

This release

1.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page