MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / demo_gotchas_and_tips

Function demo_gotchas_and_tips

python/examples/migration_guide.py:185–220  ·  view source on GitHub ↗

Show potential gotchas and migration tips.

()

Source from the content-addressed store, hash-verified

183
184
185def demo_gotchas_and_tips():
186 """Show potential gotchas and migration tips."""
187 print("\n=== Migration Tips & Potential Gotchas ===\n")
188
189 print("1. CAPACITY TUNING:")
190 print(" Default capacity (128) is good for most use cases")
191 print(" For very large datasets, consider capacity=64 or higher")
192 print(" For testing/small data, capacity=4-16 is fine")
193
194 tree_small = BPlusTreeMap(capacity=4)
195 tree_large = BPlusTreeMap(capacity=128)
196 print(f" Small capacity tree: {tree_small.capacity}")
197 print(f" Large capacity tree: {tree_large.capacity}")
198
199 print("\n2. KEY ORDERING:")
200 print(" Keys must be comparable (support <, >, ==)")
201 print(" Mixed types that can't be compared will raise TypeError")
202
203 tree = BPlusTreeMap()
204 tree[1] = "number"
205 tree["hello"] = "string"
206 # tree[None] = "none" # This would fail: None < 1 not supported
207 print(" ✓ Use consistent key types for best results")
208
209 print("\n3. WHEN NOT TO MIGRATE:")
210 print(" - Very small datasets (< 100 items)")
211 print(" - Mostly random single-key lookups")
212 print(" - Memory is extremely constrained")
213 print(" - Keys are not orderable")
214
215 print("\n4. WHEN TO DEFINITELY MIGRATE:")
216 print(" ✓ Need range queries")
217 print(" ✓ Frequently iterate in order")
218 print(" ✓ Large datasets (1000+ items)")
219 print(" ✓ Database-like access patterns")
220 print(" ✓ Pagination or 'top N' queries")
221
222
223def demo_real_world_migration():

Callers 1

mainFunction · 0.85

Calls 1

BPlusTreeMapClass · 0.90

Tested by

no test coverage detected