🛞 mywheel¶
High-performance data structures and algorithms in Python
mywheel provides efficient implementations of fundamental data structures optimized for specific use cases in graph algorithms, EDA (Electronic Design Automation), and network optimization. All implementations prioritize memory efficiency and time complexity over Python’s standard library alternatives.
🚀 Quick Start¶
Installation¶
pip install mywheel
Usage Examples¶
Doubly Linked List with O(1) Operations¶
from mywheel import Dllist, Dllink
# Create list
dlist = Dllist(0) # sentinel node
dlist.append(Dllink("A"))
dlist.append(Dllink("B"))
# O(1) operations
node = dlist.popleft() # Remove first
dlist.appendleft(Dllink("C")) # Add to front
Bounded Priority Queue for Small Integer Keys¶
from mywheel import BPQueue, Dllink
# Efficient for keys in range [-5, 5]
bpq = BPQueue(-5, 5)
# Add items with integer keys
bpq.append(Dllink("task1"), 3)
bpq.append(Dllink("task2"), 5)
# Extract highest priority item
item = bpq.popleft()
Round-Robin Iteration¶
from mywheel import Robin
# Create 5-part cycle
robin = Robin(5)
# Iterate excluding starting position
for part in robin.exclude(2):
print(part) # Prints: 3, 4, 0, 1
Array-Like Utilities¶
from mywheel import MapAdapter
# Adapt list to dict-like interface
lst = [10, 20, 30, 40]
mapping = MapAdapter(lst)
mapping[0] = 99
assert mapping[0] == 99
📊 Performance Characteristics¶
Data Structure |
Insert |
Delete |
Lookup |
Memory |
Best For |
|---|---|---|---|---|---|
|
O(1) |
O(1) |
N/A |
Minimal |
Frequent front/back operations |
|
O(1)* |
O(k) |
O(1) |
O(b-a) |
Small bounded integer keys |
|
O(n) |
N/A |
O(1) |
O(n) |
Round-robin scheduling |
|
O(1) |
N/A |
O(1) |
O(n) |
Dict-like list access |
* O(1) amortized for bounded keys
🎯 Used In¶
✨ Features¶
Memory Efficient: Uses
__slots__and sentinel nodes to minimize overheadType Safe: Full type hints with mypy support
Well Tested: 100% coverage with pytest and hypothesis
Zero Dependencies: Pure Python, no external runtime dependencies
Python 3.8+: Supports all modern Python versions
🔧 Development¶
# Clone and install
git clone https://github.com/luk036/mywheel.git
cd mywheel
pip install -e ".[testing]"
# Run tests
pytest
# Run type checking
mypy src/mywheel
# Run linting
pre-commit run --all-files
See CONTRIBUTING.md for detailed guidelines.
👉 Note¶
This project has been set up using PyScaffold 4.5. For details and usage information on PyScaffold see https://pyscaffold.org/.