go-python / go-python/gpython

Implement dict to receive Object as key, not only String

Open
#118 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1k
Forks
105
PR merge metrics
No merged PRs in 30d

Description

https://github.com/go-python/gpython/blob/33327c5231b03c84972bec57262694aebbaa1e84/py/dict.go#L68

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.
```go
make([]Object, 0, len(default_size)) // slice to store object (index -> Object)
type Dict map[HashIndex]int // map to store index of slice (Hash -> index)
```

Is it ok to implement dict this way?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.