Re: [Python-Dev] Unordered tuples/lists

2010-07-14 Thread Raymond Hettinger
On May 20, 2010, at 10:35 AM, Martin v. Löwis wrote: >> I think it'd be useful enough to go in the standard library. Now that >> there's a sample implementation, should I still try to demonstrate why I >> believe it's worth adding to the stdlib and get support? > > Most definitely. Just in case

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Gustavo Narea
Martin said: > Most definitely. Just in case it isn't clear: nobody else seems to think > this is useful (let alone useful enough to go into the standard > library). In addition, it's trivial to implement, more reason not to add > it. Yeah, fair enough. Thanks for your responses! :) -- Gustavo Na

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Martin v. Löwis
> I think it'd be useful enough to go in the standard library. Now that > there's a sample implementation, should I still try to demonstrate why I > believe it's worth adding to the stdlib and get support? Most definitely. Just in case it isn't clear: nobody else seems to think this is useful (let

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Michael Foord
On 20/05/2010 17:02, geremy condra wrote: On Wed, May 19, 2010 at 1:56 AM, Gustavo Narea wrote: Hello, Oleg. class UnorderedList(list): def __eq__(self, other): if not isinstance(other, UnorderedList): return False return sorted(self) == sorted(other)

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread geremy condra
On Wed, May 19, 2010 at 1:56 AM, Gustavo Narea wrote: > Hello, Oleg. > >> >> class UnorderedList(list): >>    def __eq__(self, other): >>        if not isinstance(other, UnorderedList): >>            return False >>        return sorted(self) == sorted(other) >> >>    def __ne__(self, other): >>  

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Steven D'Aprano
On Thu, 20 May 2010 08:40:25 pm Oleg Broytman wrote: > On Wed, May 19, 2010 at 09:56:03AM +0100, Gustavo Narea wrote: > > I think it'd be useful enough to go in the standard library. Now > > that there's a sample implementation, should I still try to > > demonstrate why I believe it's worth adding

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Oleg Broytman
On Wed, May 19, 2010 at 09:56:03AM +0100, Gustavo Narea wrote: > I think it'd be useful enough to go in the standard library. Now that > there's a sample implementation, should I still try to demonstrate why I > believe it's worth adding to the stdlib and get support? I think yes. How many deve

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Gustavo Narea
Hello, Oleg. > class UnorderedList(list): >def __eq__(self, other): >if not isinstance(other, UnorderedList): >return False >return sorted(self) == sorted(other) > >def __ne__(self, other): >return not self.__eq__(other) > > Do you need more than that

Re: [Python-Dev] Unordered tuples/lists

2010-05-20 Thread Gustavo Narea
Hi, Guido. On Wed, May 19, 2010 at 12:11 AM, Guido van Rossum wrote: > This is typically called a "bag". Maybe searching for that will help > you find a recipe? > A bag/multiset is close to what I need, except for one thing: I need to iterate over the elements in the original order, not in a ra

Re: [Python-Dev] Unordered tuples/lists

2010-05-18 Thread Ben Finney
Gustavo Narea writes: > I've been searching for a data structure like a tuple/list *but* > unordered -- like a set, but duplicated elements shouldn't be removed. By that description, you're looking for the “Bag” pattern. […] > A multiset is not exactly what I need: I still need to use the > ele

Re: [Python-Dev] Unordered tuples/lists

2010-05-18 Thread Oleg Broytman
On Tue, May 18, 2010 at 11:13:42PM +0100, Gustavo Narea wrote: > To sum up, it would behave like a tuple or a list, except when it's compared > with another object: They would be equivalent if they're both unordered > tuples/lists, and have the same elements. There can be mutable and immutable >

Re: [Python-Dev] Unordered tuples/lists

2010-05-18 Thread Steven D'Aprano
On Wed, 19 May 2010 08:13:42 am Gustavo Narea wrote: > Hello, everybody. > > I've been searching for a data structure like a tuple/list *but* > unordered -- like a set, but duplicated elements shouldn't be > removed. I have not even found a recipe, so I'd like to write an > implementation and contr

Re: [Python-Dev] Unordered tuples/lists

2010-05-18 Thread Benjamin Peterson
2010/5/18 Guido van Rossum : > This is typically called a "bag". Maybe searching for that will help > you find a recipe? Yes, and we have one in Python 2.7+ called collections.Counter. -- Regards, Benjamin ___ Python-Dev mailing list Python-Dev@python

Re: [Python-Dev] Unordered tuples/lists

2010-05-18 Thread Guido van Rossum
This is typically called a "bag". Maybe searching for that will help you find a recipe? On Tue, May 18, 2010 at 3:13 PM, Gustavo Narea wrote: > Hello, everybody. > > I've been searching for a data structure like a tuple/list *but* unordered -- > like a set, but duplicated elements shouldn't be re

[Python-Dev] Unordered tuples/lists

2010-05-18 Thread Gustavo Narea
Hello, everybody. I've been searching for a data structure like a tuple/list *but* unordered -- like a set, but duplicated elements shouldn't be removed. I have not even found a recipe, so I'd like to write an implementation and contribute it to the "collections" module in the standard library.