-
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: x/exp/maps: add Merge #57191
Comments
what's the proposed API? |
Here's the proposed API What I'm saying is
The other benefit of this function is the ability to allocate one time to hold every values in a single map. |
I don't know: the maps.Clone+maps.Copy implementation seems more explicit to me. There is no ambiguity about which maps override which other maps. I don't understand the comment about the benefit of "the ability to allocate one time". Perhaps this is talking about precalculating the size of the map and preallocating, but that doesn't end up working that well for maps, and it's difficult to predict the amount of overlap anyway. If m1 through m5 contain mostly the same keys, you need max(len(mX)) for the result. If they contain mostly different keys, you need sum(len(mX)) for the result. Those are very different preallocated sizes. |
This also doesn't seem like a very common operation. How important is this? How often does it come up? |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
Sorry, I forgot to answer ! It is quite right for the rule about the overrides. It is probably not frequent enough to justify its use instead of using a loop with maps.Copy. |
No change in consensus, so declined. |
Prior to my PR, I didn't see that this feature was already discussed here.
Even though the change was retracted in favor of
maps.Copy
, I believe that for a large number of maps to merge, the semantics of aMerge
function are more meaningful.The implementation I've proposed has no mechanism for key conflicts resolution.
But this mechanism (if implemented) could possibly justify this function existence alongside
maps.Copy
.The text was updated successfully, but these errors were encountered: