Author jab
Recipients gvanrossum, jab, rhettinger
Date 2016-12-09.05:18:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Come to think of it, to be exact, rather than extending Reversible, OrderedMapping could extend a narrower interface, something like, along with extending Mapping. (Reversible implies Ordered, but Ordered does not imply Reversible: a singly-linked list is Ordered but not Reversible, for example.)

I guess we don't currently have Ordered because it wouldn't necessarily add any abstractmethods beyond what Iterable already provides. But it could provide a generic, concrete __eq__ implementation, something like:

class Ordered(Iterable):
    def __eq__(self, other):
        if not isinstance(other, Ordered):
            return NotImplemented
        return all(i == j for (i, j) in zip(self, other))

which is not something that any existing Iterable currently provides.

Even if an Ordered interface that's totally empty were available in the standard library, then Iterables across diparate codebases could opt into extending it as a standard signal that they iterate over their elements in a well-defined order, and could participate in other polymorphic code. Currently we have no such standard signal, do we?
Date User Action Args
2016-12-09 05:18:30jabsetrecipients: + jab, gvanrossum, rhettinger
2016-12-09 05:18:30jabsetmessageid: <>
2016-12-09 05:18:30jablinkissue28912 messages
2016-12-09 05:18:29jabcreate