[Python-ideas] Proposal for extending the collections module - bags / multisets, ordered sets / unique lists

Mike Meyer mwm-keyword-python.b4bdba at mired.org
Sat Jul 18 05:48:04 CEST 2009


On Sat, 18 Jul 2009 12:58:18 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:

> Michael Lenzen wrote:
> > In a nutshell, I want to add 2 new classes (and respective frozen
> > varients) to the collections module, namely a bag (multiset) class and a
> > setlist (ordered set/unique list) class.  I know this has been floated
> > before, but I think it merits more consideration.
> 
> A Counter class (aka bag/multiset) and an OrderedDict class were added
> to collections for 3.1. These classes will also be available in 2.7.
> 
> Counter *is* a bag implementation, while OrderedDict can trivially be
> used as the basis for an OrderedSet implementation.

If that's good enough, why do we have set?

More importantly, will the ones that you don't have to write yourself
all have the same API? It would be nice to be able to change between
the four cases as the requirements change without having to audit
every use of them to turn the spelling of add_element_to_type_x into
add_element_to_type_y, and so on.

       <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the Python-ideas mailing list