Trees

Rustom Mody rustompmody at gmail.com
Wed Jan 21 07:09:06 EST 2015


On Wednesday, January 21, 2015 at 1:27:39 PM UTC+5:30, Stephen Hansen wrote:
> On Tue, Jan 20, 2015 at 1:45 AM, Marko Rauhamaa <ma... at pacujo.net> wrote:
> Terry Reedy <tjr... at udel.edu>:
> 
> 
> 
> > Others have answered as to why other special-purpose
> 
> > constrained-structure trees have not been added to the stdlib.
> 
> 
> 
> Ordered O(log n) mappings are not special-purpose data structures. I'd
> 
> say strings and floats are much more special-purpose than ordered
> 
> mappings, and yet Python has direct support for those.
> 
> 
> 
> Your anecdote is strong, sir.
> 
> 
> However, I use strings thousands of times, floats maybe a hundred of times, and order mappings a few times.
> 
> 
> My anecdote counters yours.
> 
> 
> A tree structure is special purpose because there is a lot of options with different characteristics that make certain implementations ideal in some cases and not in others.
> 
> 
> A float is a float, there's a standard (IEEE 754?), its not special at all.
> 
> 
> A string, I suppose, could be special, but that's a pretty nonsense view of the world since what most people use strings commonly. 
> 
> 
> I'm not arguing against including a tree, but I have no advice on which one, and the one-- one!-- time I've needed a tree I got one off pypi. Not everything needs to be in the stdlib.
> 
> 
> But to call strings and floats special purpose is really a silly argument to make. 

Since we are trading anecdotes…

Among my teachers of CS, there were two – both brilliant — one taught me
Numerical Analysis, the other taught me programming.

[As it happens my initial practical programming was the numerical kind
because the Fortran compiler was more serviceable than the Pascal one.
But thats a different point]

The point is that the two of them disagreed strongly on what programming was
about.

The numerical analyst could see no earthly reason to use anything other than
Fortran.

The programmer had horror stories to tell about how Fortran damages the brain:
eg programs that inherently need a while-loop (eg binary search) seem to be
distinctly out of the reach of the Fortran programmer.  Recursion...
And much else.

The numerical analyst of course had no use for this philosophizing.

The view that strings and floats are more fundamental than containers and maps
reminds me of this view.

For me python is neat because I can write: [1,2,3]
when I want a list.

But it does not go nearly far enough.

I would like a set to be {1,2,3} or at worst ⦃1,2,3⦄
and a bag to be ⟅1,2,3⟆

Apart from the unicode niceness that Ive described here
http://blog.languager.org/2014/04/unicoded-python.html

Its a bit of a nuisance that we have to write set([1,2,3]) for the first

More irksome that for the second we've to preface with

from collections import Counter

And still more a PITA that a straightforward standard name like bag (or multiset)
is called by such an ungoogleable misleading name as counter.



More information about the Python-list mailing list