-
Notifications
You must be signed in to change notification settings - Fork 95
Implement dict to receive Object as key, not only String #118
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Comments
@HyeockJinKim type Dict struct {
...
}
func (d *Dict) Put(...) (Object, error) {
...
}
func (d *Dict) Get(...) (Object, error) {
...
} cc @ncw |
cc @sbinet |
if I am not mistaken, so, couldn't we just use |
@sbinet
He might want to implement this feature. |
@HyeockJinKim |
I stand corrected :) ok, then what about: type Dict struct {
keys map[Object]int // key to index into slice of vals
vals []Object // values associated with the above keys
} (I think we can rely on Go's map hashing mechanism) |
and if we want to retain insertion order: type Dict struct {
keys map[Object]int
items [][2]Object // key-value pair
} |
Does anyone have a fork for this issue? Would be willing to give it a shot. |
@ashermancinelli please ping to @HyeockJinKim |
I'm working on this issue right now. |
Implement dict struct that takes Object as key store key and value in array together so that dict is ordered Issue go-python#118
gpython/py/dict.go
Line 68 in 33327c5
Change the dict to receive a hashable object as a key, not just a string.
I will change it so that the object can be looked up through the hash value of the object.
Store the object in the slice and use the map to find the index of the stored object through the hash value.
Is it ok to implement dict this way?
The text was updated successfully, but these errors were encountered: