3 ms·
Not a strict requirement, but hashing pointer values. In Go, a pointer's integer value may not be stable since the GC may move the underlying data. This doesn'
by uluyol 6y ago
Not a strict requirement, but hashing pointer values.
In Go, a pointer's integer value may not be stable since the GC may move the underlying data. This doesn't happen with today's runtime, but it may in the future.
Why does this matter? What if I want to make a hash table with the key being a pointer? The built-in map can just go ahead and hash the pointer itself (i.e. a 32/64-bit integer) since it's a part of the runtime and will be updated if the GC is changed. But a user map cannot do this: it would have to hash the actual value itself. Depending on your data, this could be significantly more expensive.
This doesn't stop anyone from implementing a hash table, but it may mean that it can't be as fast as the built-in map.