[Python-ideas] Tree as a data structure (Was: Graph class)

Antoine Pitrou solipsis at pitrou.net
Fri Dec 21 11:51:18 CET 2012


Jim Jewett <jimjjewett at ...> writes:
> 
> On 12/19/12, anatoly techtonik <techtonik at ...> wrote:
> > On Sun, Dec 16, 2012 at 6:41 PM, Guido van Rossum <guido at ...> wrote:
> 
> >> I think of graphs and trees as patterns, not data structures.
> 
> > In my world strings, ints and lists are 1D data types, and tree can be a
> > very important 2D data structure.
> 
> Yes; the catch is that the details of that data structure will differ
> depending on the problem.  Most problems do not need the fancy
> algorithms -- or the extra overhead that supports them.  Since a
> simple tree (or graph) is easy to write, and the fiddly details are
> often -- but not always -- wasted overhead, it doesn't make sense to
> designate a single physical structure as "the" tree (or graph)
> representation.

Do you care about the overhead of an OrderedDict? As long as you are not 
manipulating a huge amount of data, a generic tree structure such as provided
by e.g. the networkx library is perfectly fine.

And if you want to reimplement a more optimized structure, sure, that's fine.
But that's not an argument against a generic data structure that would be
sufficient for 99.9% of all use cases.

Regards

Antoine.





More information about the Python-ideas mailing list