You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the first time I've used the container/list package, what is the overhead you're referring to?
Separate allocation of list.Element and orderedMapElement. Excess interface pointer from list.Element to orderedMapElement. Excess interface casting for taking orderedMapElement from list.Element.Value.
I'd rather call your implementation “naive” or “lazy” (in term “I was lazy to do low level code by hand, so I took standard library despite it is not for high performance but for lazy programmers”).
Reacted by Hunter Loftis, Frédéric G. MARAND, elke and Andy Schönfeld
I take your point. However “high performance” is a relative term, not a quantitative one. If it bothers you, then I’m happy to review a PR with improvements.
Reacted by 泰戈尔, Kaitian Xie, syncore, Samson Rapando, Hunter Loftis, Jamie Holland, Frédéric G. MARAND and elke
Activity
elliotchance commentedon Nov 15, 2019
This is the first time I've used the
container/listpackage, what is the overhead you're referring to?guoruibiao commentedon Nov 15, 2019
it seems that
orderedmapis just the wrapper of list.[Element+List]caelaxie commentedon Nov 16, 2019
The linked list is used to record the insertion order. This is how OrderedDict is implemented in Python as well (see: https://stackoverflow.com/questions/34496582/is-ordereddict-a-tree).
caelaxie commentedon Nov 16, 2019
Also: https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html
funny-falcon commentedon Nov 16, 2019
Separate allocation of list.Element and orderedMapElement. Excess interface pointer from list.Element to orderedMapElement. Excess interface casting for taking orderedMapElement from list.Element.Value.
I'd rather call your implementation “naive” or “lazy” (in term “I was lazy to do low level code by hand, so I took standard library despite it is not for high performance but for lazy programmers”).
funny-falcon commentedon Nov 16, 2019
I mean, it is not bad to be lazy. Being lazy helps to do less mistakes, and to write more code that has business value.
But “high performance” code in Go could not be written in lazy way.
Just don't call it “high performance”.
elliotchance commentedon Nov 17, 2019
I take your point. However “high performance” is a relative term, not a quantitative one. If it bothers you, then I’m happy to review a PR with improvements.
rocaltair commentedon Sep 14, 2020
How can you say it is a orderedmap? with O(1) ?
elliotchance commentedon Sep 14, 2020
It will maintain the keys in the order they were inserted. This is something Go does not do natively with maps.
This means operations (Len, Get, Set etc) takes about the same amount of time, regardless of the size of the underlying orderedmap.