gpython
gpython copied to clipboard
Implement Hash of object
We have to calculate the hash according to the type of Object and return a value.
There is currently M__hash__ but it is not implemented in any Object.
type I__hash__ interface {
M__hash__() (Object, error)
}
First, we have to implement M__hash__ of numbers and strings(int, float, complex, string).
This is also necessary for the implementation of the dictionary.
I note that in go1.14 the go team have exported the internal hasher
https://github.com/golang/go/commit/bf36219cdd1d354d58107ed8903679f538948154
This makes uint64 hashes which would work very well for our purpose.
That said we could start with a much simpler hashing function.