Show migration from SortedDict to BPlusTree.
()
| 65 | |
| 66 | |
| 67 | def demo_sorteddict_migration(): |
| 68 | """Show migration from SortedDict to BPlusTree.""" |
| 69 | print("\n=== Migrating from SortedDict to BPlusTree ===\n") |
| 70 | |
| 71 | try: |
| 72 | from sortedcontainers import SortedDict |
| 73 | |
| 74 | print("BEFORE (using SortedDict):") |
| 75 | print("```python") |
| 76 | print("from sortedcontainers import SortedDict") |
| 77 | print("data = SortedDict()") |
| 78 | print("# ... same operations ...") |
| 79 | print("```") |
| 80 | |
| 81 | # SortedDict example |
| 82 | sorted_data = SortedDict() |
| 83 | sorted_data.update({5: "five", 1: "one", 3: "three"}) |
| 84 | print(f"SortedDict: {list(sorted_data.items())}") |
| 85 | |
| 86 | except ImportError: |
| 87 | print("SortedDict not available, showing conceptual migration:") |
| 88 | |
| 89 | print("\nAFTER (using BPlusTree):") |
| 90 | print("```python") |
| 91 | print("from bplustree import BPlusTreeMap") |
| 92 | print("data = BPlusTreeMap(capacity=64) # Optional: tune for performance") |
| 93 | print("# ... same operations ...") |
| 94 | print("```") |
| 95 | |
| 96 | # BPlusTree equivalent |
| 97 | bplus_data = BPlusTreeMap(capacity=64) |
| 98 | bplus_data.update({5: "five", 1: "one", 3: "three"}) |
| 99 | print(f"BPlusTree: {list(bplus_data.items())}") |
| 100 | print("✓ Same sorted behavior, potentially better performance!") |
| 101 | |
| 102 | |
| 103 | def demo_api_compatibility(): |
no test coverage detected