Hacker News new | past | comments | ask | show | jobs | submit login

Using a sequence instead of a map is fine if you know it will never be more than some small number of entries, but so often we are wrong about how many entries will be in a table that the N-squared use of a sequence as a map kills performance unexpectedly.



But that's what profiling is for.


That argument favours hashmaps by default, though. After all, they're all right at small sizes and much better at big sizes.


Profiling won't tell you what the chances are that the collection will someday need to contain more than N elements.


You don't replace every map in your code with a distributed Key-Value store, in case it might need to store terabytes in the future. Most of the time you have a pretty good idea whether a map has to store a hundred, or a hundred thousand elements.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: