2 ms·
> "In this post, I have chosen to implement it as a binary search tree. There are a few reasons, most prominently because I wanted to eschew using anything more
by AkshatM 10y ago
> "In this post, I have chosen to implement it as a binary search tree. There are a few reasons, most prominently because I wanted to eschew using anything more sophisticated than basic Python, and using a sorted list efficiently would mean resorting to Python’s bisect."
Other reasons:
- Other blog posts about consistent hashing fall prey to favouring 'clever' implementations, which is great for advanced Pythonistas, but serves to obfuscate for anyone else. Similar arguments hold for many existing BST implementations.
- Implementing the custom lookup I sought for this implementation was easier if I went with something hand-rolled, and was fine since I don't expect anyone to actually use this implementation in production (I mean, they can, but there are better implementations out there).
Essentially, my goal was transparency and clarity. This was the best way to do it, all things considered.