On Mar 11, 2013, at 4:48 PM, Stephen McInerney wrote:
> I'm looking for advice (and also good overviews) on tree and trie implementations in
> Python. I already did some reading and it's a tower of Babel out there (StackOverflow , pypi, macports etc.); I can't find any good overviews. Apparently figuring out which package to use causes severe grief, especially to people from other languages where these exist in stdlib.
>> In my current use case I need an n-ary tree or trie to store 32,000 UK regions and placenames.
> Max depth is 6. The keys are strings, possibly multiword. The values should be arbitrary objects. Must run on a Mac.
>
What is it you are not getting from simply using the dictionary type containing some Place objects?
Why not a Places object which owns a dictionary. places.add_place would add a new place to the top of the dict and potentially to any sub trees it would belong in. places.lookup would find the place in question and return whatever it is you need. Deleting an object could be painful but I doubt you lose cities all that often :-)
If you are worried about a Python dictionary holding 32K elements then I suspect your concerns are unfounded unless you have done some testing and found issues.