gpython icon indicating copy to clipboard operation
gpython copied to clipboard

Implement Hash of object

Open HyeockJinKim opened this issue 6 years ago • 1 comments

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.

HyeockJinKim avatar Oct 20 '19 05:10 HyeockJinKim

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.

ncw avatar Oct 21 '19 20:10 ncw