This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Can I merge two trie with pygtrie? #40
Comments
What do you mean by ‘merge’? Trie implements Mapping interface so update indeed does overwrite keys. |
'merge' mean 'update recursively', like merge binary tree |
That still doesn’t explain what you expect to happen when merging to tries which contain the same key. |
While update, a trie contains {
"foo": {
"bar1": "1",
"bar2": "2"
}
} Updated by another trie contains {
"foo": {
"bar3": "3",
}
} Would got {
"foo": {
"bar3": "3",
}
} Following key would overwrite. {
"foo": {
"bar1": "1",
"bar2": "2",
"bar3": "3"
}
} I mean if tries contains same key, and the key refer a sub trie, then merge would update the sub trie, but not overwrite which will drop out sub trie |
mina86
added a commit
to mina86/pygtrie
that referenced
this issue
Jul 10, 2022
Trie.merge method allows two tries to be merged structurally which is often faster than looping over all items and setting them individually in destination trie. The operation doesn’t check that the tries are of the same type so it may result in keys being transformed in one way or another. Issue: google#40
mina86
added a commit
to mina86/pygtrie
that referenced
this issue
Jul 16, 2022
mina86
added a commit
to mina86/pygtrie
that referenced
this issue
Jul 16, 2022
mina86
added a commit
to mina86/pygtrie
that referenced
this issue
Jul 16, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It seems update is just overwrite, same as dict.update
The text was updated successfully, but these errors were encountered: