[Python-3000] ordered dict for p3k collections?

Guido van Rossum guido at python.org
Tue Sep 25 20:06:04 CEST 2007


On 9/25/07, Mark Summerfield <mark at qtrac.eu> wrote:
> 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), ...).

Why would this be a problem? There is no requirement that sorteddict()
support this feature.

> 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).

For that to happen, someone has to write a production-quality
implementation, release it as a separate 3rd party module for a while,
show that it is sufficiently stable and popular to be incorporated in
the standard library, and commit to maintaining it for a few years at
least. (It doesn't have to be all the same someone.)

Hoping and wishing doesn't cause working code to spring into existence.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list