Author jab
Recipients gvanrossum, jab, rhettinger
Date 2016-12-09.05:18:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481260710.25.0.228215629872.issue28912@psf.upfronthosting.co.za>
In-reply-to
Content
Come to think of it, to be exact, rather than extending Reversible, OrderedMapping could extend a narrower interface, something like collections.abc.Ordered, 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 collections.abc 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?
History
Date User Action Args
2016-12-09 05:18:30jabsetrecipients: + jab, gvanrossum, rhettinger
2016-12-09 05:18:30jabsetmessageid: <1481260710.25.0.228215629872.issue28912@psf.upfronthosting.co.za>
2016-12-09 05:18:30jablinkissue28912 messages
2016-12-09 05:18:29jabcreate