6 ms·
ELI5. How is maphash different from just using map? I am surely missing something. I thought the builtin map used hashing too?
by shp0ngle 4y ago
ELI5. How is maphash different from just using map?
I am surely missing something. I thought the builtin map used hashing too?
- barsonme 4y agoThe maphash package from the blog post provides routines that call into Go's runtime to hash arbitrary types. The maphash package in the standard library (hash/maphash) provides routines that hash string and []byte. The builtin map type is a hash table.
- shp0ngle 4y agoAhh I somehow misread the post and thought it’s a generic map that uses hash table. I should get some sleep, thanks
- AaronFriel 4y agoMaphash is a library for computing hashes of arbitrary types in Go, not a map data structure.
- codesniperjoe 4y agoMaphash is an (non-cryptographic-secure) hash function, like CRC32 / CRC64 / XXH3-64 and others, so it turns data in an (almost) uniq uint64. The main difference is, it is an hardware accelerated & optimized compiler function, now exposed via the new maphash package in stdlib. And it is fast. Faster than the former performance leader xxh3(avx2/avx512). Try maphash yourself (example data dedupliction) https://news.ycombinator.com/item?id=34091206 https://news.ycombinator.com/item?id=34091206