sorteddict PEP proposal [started off as orderedict]

Bryan Olson fakeaddress at nowhere.org
Thu Sep 27 04:11:29 EDT 2007


Mark Summerfield wrote:
> The sorteddict API that has emerged so far is (1) apart from the
> constructor, everything is identical to dict, (2) the constructor
> takes the same args as sorted(), so if you want to seed with a dict or
> with keywords you write sorteddict(dict(a=1,b=2), ...), (or you could
> create a sorteddict and use update() since that takes the same args as
> dict's constructor).
> 
> Could your AVLTree support cmp and keys and reverse?


I think you are expending too much effort on the no-brainers.
Yes, AVL-trees can support cmp and keys and reverse. I cannot
speak for Antoon, but have no doubt that adapting his code to
do so is within his ability.

Hrvoje Niksic is right that a simple layer over existing
hashed dicts "dooms the PEP to rejection". Thus the candidate
algorithms are the approximately-balanced tree structures:
AVL trees, red-black trees, 2-3 trees, b-trees, splay trees,
or skip-lists.

Implementing these is non-trivial, but easily within the
ability of many people here. Don't worry about the coding.


-- 
--Bryan



More information about the Python-list mailing list