top | item 45739652

(no title)

lurquer | 4 months ago

In C++, I’ve noticed that ChatGPT is fixated on unordered_maps. No matter the situation, when I ask what container would be wise to use, it’s always inordered_maps. Even when you tell it the container will have at most a few hundred elements (a size that would allow you to iterate their a vector to find what your are looking for before the unordered_map even has its morning coffee) it pushes the map… with enough prodding, it will eventually concede that a vector pretty much beats everything for small .size()’s.

discuss

order

jcelerier|4 months ago

> (a size that would allow you to iterate their a vector to find what your are looking for before the unordered_map even has its morning coffee)

I don't know about this, whenever I've benchmarked it on my use cases, unordered_map started to become faster than vector at well below 100 elements

bmandale|4 months ago

I agree with chatgpt here

remexre|4 months ago

isn't std::unordered_map famously slow, and you really want the hashmap from abseil, or boost, or folly, or [...]