[Python-Dev] PEP 372 -- Adding an ordered directory to collections ready for pronouncement

Steven D'Aprano steve at pearwood.info
Wed Mar 4 18:21:50 CET 2009

Leif Walsh wrote:
> On Wed, Mar 4, 2009 at 7:53 AM,  <rdmurray at bitdance.com> wrote:
>> I actually like StableDict best.  When I hear that I think, "ah, the
>> key order is stable in the face of insertions, unlike a regular dict".
>> Nor can I at the moment think of an alternative explanation of what a
>> "StableDict" might be.
> Hmm, perhaps a better explanation than a hasty +1:
> "stabledict" makes me think of merge sort, being a stable sort.

Why merge sort in particular? Why not bubble sort, heap sort, insertion 
sort or any one of many other stable sorts?

Is this analogy really simpler than merely learning the fact that the 
dict keys are kept in the order they are inserted? It's not a very 
difficult concept. Why are we complicating it by inventing obscure, 
complicated analogies with utterly unrelated functions?

 > In
> the same way that merge sort doesn't needlessly swap elements while
> sorting, stabledict might be thought to not "needlessly" swap elements
> while {inserting, deleting}.

You're drawing an awfully long bow here. One might equally argue that in 
the same way that bubble sort does lots and lots of swapping, stabledict 
might be thought to be horribly inefficient and slow.

> I also can't think of an alternative
> explanation, so thus far, it's resistant to false positive semantics.

"The keys don't expire with time."
"It's stable against accidental deletions."
"It's stable against accidentally over-writing values."


More information about the Python-Dev mailing list