Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement dict to receive Object as key, not only String #118
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

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

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?