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.

Metadata

Release files for data-structures-lib 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for data-structures-lib 1.1.0
File Size Uploaded Provenance
data_structures_lib-1.1.0.tar.gz 13.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for data-structures-lib 1.1.0
File Interpreter ABI Platform
data_structures_lib-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / data_structures_lib-1.1.0.tar.gz

Download URL data_structures_lib-1.1.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a2707bbf1d3b433a570062acd5bf6bdc4d72224b8b279f32b84b64d7fb1d75b2
BLAKE2b-256 checksum
How to use checksums
a97dc36597c6e7c52397e7c2ed5d0c2e721c8700484d9f052380e81600dac174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / data_structures_lib-1.1.0-py3-none-any.whl

Download URL data_structures_lib-1.1.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19bb9d3e60f854bdbb112a6426d7ff65ee087ac3ca028b138f3a7be2ce240f12
BLAKE2b-256 checksum
How to use checksums
20ea9444a49bbefd730cf4937678693345a4d4d966b698e1fa476f999e58b84d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for data-structures-lib 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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