[Python-ideas] Indicate if an iterable is ordered or not

Eric Snow ericsnowcurrently at gmail.com
Wed Sep 25 01:10:38 CEST 2013

FYI, at this point I not longer have a use case for this feature, and
I'm not in favor of this idea without one.

On Tue, Sep 24, 2013 at 3:16 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> The iterator protocol is intentionally simple.  It only requires an __iter__
> method or a __next__ method with a standard __iter__ method. This makes
> iterables -- and generator functions that produce iterators -- easy to
> write.

This is not a proposal for an addition to the iterator protocol.  It
is about indicating (without iterating) that the iteration order of
instances of a particular class will be consistent.

> A generator instance may and may not produce items in an intented order, so
> a class attribute is not possible. The same is generally true of transform
> iterators, like map and filter instances, and most itertools classes.  It is
> also not true that lists (and tuples) always have a significant order.
> list(set) has the artificial order of set iteration.  Both are reiterable
> with the same order. Why would you call one True and the other False? In
> general, list(iterable) has as much order as the iterable.

However, once values are added to the list, that order is consistent.


More information about the Python-ideas mailing list