[Python-Dev] PEP 372 -- Adding an ordered directory to collections ready for pronouncement
Glenn Linderman
v+python at g.nevcal.com
Wed Mar 4 09:01:55 CET 2009
On approximately 3/3/2009 11:22 PM, came the following characters from
the keyboard of Raymond Hettinger:
>
>>> Perhaps the terminology should be
>>>
>>> ordereddict -- what we have here
>>>
>>> sorteddict -- hypothetical future type that keeps
>>> itself sorted in key order
>
> +1
-1
Introducing the hypothetical sorteddict would serve to reduce the
likelihood of ordereddict being interpreted as sorteddict among the
small percentage of people that actually read the two lines that might
mention it in the documentation, but wouldn't significantly aid the
intuition of people who first encounter it in someone else's code.
And without an implementation, it would otherwise be documentation
noise, not signal.
>> FIFOdict ? Yeah, that blows the capitalization scheme, way, way out.
>
> Issues:
> * The popitem() method is LIFO.
But traversal starts at the other end, if I understand correctly.
popitem seems gratuitous (but handy and cheap)
> * In a non-popping context, there is no OUT. It just stores.
> * FIFO is more suggestive of queue behavior which does not apply here.
It is suggestive of queue behavior, and the items are a queue if looked
at from insertion, and traversal perspectives, if I understand
correctly. But without OUT, FIFO is a bit too aggressively suggestively
of queues... but not more so than ordereddict is a bit too suggestive
of sorted behavior... And at least FIFO doesn't have the sorting
connotation.
> * Stores to existing keys don't go at the end; they leave the order
> unchanged.
>
> FWIW, PEP 372 has links to seven other independent implementations and
> they all have names that are some variant spelling OrderedDict except
> for one which goes by the mysterious name of StableDict.
Well, just because six other independent implementations use a name with
connotations that they don't live up to is no reason to perpetuate such
foolishness, nor introduce it into the Python stdlib.
StableDict, eh? That's not so mysterious, perhaps, if you think of
stable sorts^H^H^H^H^H (whoops, there's the wrong connotation rearing
its ugly head again, sorry).
> Am still +1 on painting the class green with pink polka dots, but I'm
> starting to appreciate why others are insisting on pink with green polka
> dots ;-)
Sure. I didn't expect FIFOdict to be an extremely useful suggestion,
but I wanted to make the point that if the name has an erroneous
connotation, use a name that doesn't. And to get the discussion above
flowing, to find out more about your thinking in the matter.
InputOrderedDict might be more descriptive, yet not as long as that
other atrocity I alluded to that you rightfully refused to quote :)
From tree-walking, perhaps people would intuit the right connotations
from InOrderDict which is no longer than ordereddict, but usually the
tree is kept sorted too, so I'm afraid it might not be sufficient.
Maybe SequenceDict ? SeqPreservingDict ? SeqDict ? All of these talk
about sequences, which are generally not implied to be sorted. I like
these well enough, and it is late enough, that I'm not going to think of
more right now.
C'mon folks, brainstorm, don't complain about ordereddict if you can't
come up with some alternatives for discussion!!! (and some reasons why
the suggestions might be good or bad) Even your bad ideas might trigger
a good name in someone else's head...
--
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to remove.
-- Stuart Cheshire, Apple Computer, regarding Zero Configuration Networking
More information about the Python-Dev
mailing list