A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-May/100173.html below:

[Python-Dev] Unordered tuples/lists

[Python-Dev] Unordered tuples/listsBen Finney ben+python at benfinney.id.au
Wed May 19 02:19:07 CEST 2010
Gustavo Narea <me at gustavonarea.net> 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
> elements in the order they were given.

This appears to contradict your explicit request that the collection
type be unordered.

[…]
> 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 editions (UnorderedList and UnorderedTuple,
> respectively).

Okay, so you want something rather special; it would be misleading to
call this an unordered type, since you *do* want ordering preserved.
It's only the comparison operators that would ignore ordering.

AFAIK you'll need to design and implement this yourself.

> I will write a PEP to elaborate on this if you think it'd be nice to
> have. Or, should I have written the PEP first?

Either way; but I think this discussion belongs on ‘python-ideas’ while
the behaviour is still being designed.

-- 
 \      “On the internet you simply can't outsource parenting.” —Eliza |
  `\      Cussen, _Top 10 Internet Filter Lies_, The Punch, 2010-03-25 |
_o__)                                                                  |
Ben Finney

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4