On 2007-09-25, Guido van Rossum wrote: > On 9/25/07, Mark Summerfield <[EMAIL PROTECTED]> wrote: > > I can understand your personal preference for dict, although mine is for > > sorteddict---but IMO Python should provide both since both are > > legitimate in appropriate contexts. > > Careful what you wish for. > > One of Python's strengths is that there is *not* a lot of choice in > data type implementations (unless you go to relatively obscure places > like the collections module or 3rd party extensions). This saves > programmers time because they don't have to decide what data type > implementation to use in cases where it doesn't matter (and that's the > majority of cases). > > This is not a rationalization after the fact: it has always been a > specific design goal in Python to minimize the number of decisions > that a programmer must make up front. This goal also minimizes the > danger that the *wrong* decision is made, as the standard data types > are pretty darn good for almost any purpose.
My proposal was for the sorteddict to be put in the collections module, not as a builtin. One of the things I particularly like about Python is that the core language is small. However, I think that the collections module is rather thin, and as you say, it is "obscure" so won't get in the way of inexperienced or casual users if it is beefed up a bit, yet could be really useful to more demanding users. On comp.lang.python, a respondent called Paul Hankin suggested a somewhat different approach to mine: he proposed a sorteddict with the same API as a dict but with a constructor that is similar to the sorted() function: sorteddict((mapping | sequence | nothing), cmp=None, key=None, reverse=None) He points out that this has a problem with keyword argument dictionaries, but that one solution is sorteddict(dict(**kwargs), ...). >From comments other people have made on this list and on comp.lang.python, it may be that Paul Hankin's approach is more popular and better than the one I proposed---the only downside being that he didn't give any hints as to an implementation. I am hoping that Python 2.6 (and 3.0) will have a sorted dictionary of some kind, and I get the impression that it would be welcomed (in the standard library). -- Mark Summerfield, Qtrac Ltd., www.qtrac.eu _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com