-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “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? Sign in to your account
proposal: spec: user-defined map keys #283
Comments
Moving priority-someday to the Unplanned milestone. |
This is based on a POC from Frank Somers. This is a workaround for golang/go#283. Before: BenchmarkBigMapWithCompositeKeys-8 2000 2863709 ns/op After: BenchmarkBigMapWithCompositeKeys-8 10000000 573 ns/op Unsurprisingly, the O(N) implementation is super slow with a map size of 10000 entries, compared to the O(1) implementation. Change-Id: Ia9ed056218c59e77b64aceb59e23b95d37760e85
You could maybe use https://tip.golang.org/pkg/reflect/#StructOf instead of a map, to make compound keys with arbitrary components. |
I'm going to close this. If we had generics (#15292) that would be a better approach to this. Or, write your own wrapper functions that use a map[uint64][]T and write a hash function from T to uint64 and code that uses your equals function on each element in the slice. Or something like that. Anyhow, we aren't going to add this particular case to the language itself, except via generics. |
by jbamsterdam:
The text was updated successfully, but these errors were encountered: