pygtrie
pygtrie copied to clipboard
Get a sub-trie
I see has_subtrtie.
I don't see a get_subtrie. Is there a reason or has it just not been implemented? 🤔
I see _get_node, but is protected...
https://github.com/mina86/pygtrie/blob/c0dd5345df005e7b80f5950fba68d6920d72d42f/pygtrie.py#L847-L852
https://github.com/mina86/pygtrie/blob/c0dd5345df005e7b80f5950fba68d6920d72d42f/pygtrie.py#L833-L834
What are you trying to do? You can iterate over items in a subtrie by passing argument to iteritems, e.g. trie.iteritems(prefix='foobar').
get_subtrie is not implemented because no one did it and semantics of it are not necessarily obvious in regards to concurrent modifications of the trie.
@mina86 I was previously using multiple StringTrie instances but I realized I should just merge them all in to one...
... but all my unit tests assume separate instances, so I was hoping to be lazy and get get_subtrie to preserve previous behaviors 😁
Good point on modification semantics 🤔
For now I'll modify my unit tests. Perhaps I'll just leave this issue open in case anyone else wants it, and can figure out if/how it should be implemented in the future?