Joshua Bronson added the comment:

Sorry to hear but thanks for the consideration. To follow up on your comments:

> nice to see Guido's reasons for giving a -0 on the proposal.

(Guido was giving his -0 on a proposal for collections.abc.Ordered, whereas the 
main proposal here is collections.abc.OrderedMapping, sorry if that was 
confusing.)


> I would add that I haven't see any code in the wild that would benefit from 
> testing isinstance(m, OrderedMapping) and taking some different action 
> depending on the result.

Just to give you another data point, bidict.orderedbidict has been released 
into the wild for a little over 10 months, and people are using it. 
OrderedMapping would give users the following benefits:

>>> noble = orderedbidict([(2, 'helium'), (10, 'neon'), (18, 'argon')])

>>> b = bidict(noble)  # Discards the order.
>>> b  # Calls BidictBase.__repr__.
bidict({10: 'neon', 18: 'argon', 2: 'helium'})

>>> noble  # Also calls BidictBase.__repr__.
orderedbidict([('Cairo', 'Egypt'), ('Lima', 'Peru'), ('Tokyo', 'Japan')])

>>> # i.e. BidictBase.__repr__ interrogates isinstance(self, OrderedMapping)
>>> # to reflect any ordering correctly in the string representation.

>>> # OrderedMapping.__eq__ also checks isinstance(other, OrderedMapping)
>>> # to conditionally turn on order-sensitivity:
>>> noble == collections.OrderedDict(noble.items())
True
>>> noble == collections.OrderedDict(reversed(noble.items()))
False
>>> noble == dict(reversed(noble.items()))  # order-insensitive
True

(collections.OrderedDict and sortedcontainers.SortedDict could reap these same 
benefits from an OrderedMapping class.)


> Grant's sortedcollection is more sequence-like than mapping-like and the 
> bidict has its own interesting properties and neither are substitutable for 
> an OrderedDict.

Hm, I don't quite follow this. OrderedDict, SortedDict, and orderedbidict are 
all OrderedMappings, and should therefore be passable to any function that 
expects an OrderedMapping.

This part I do follow:

> In other words, the only properties these cluster on is the ordered equality 
> feature.  IMO, that particular feature hasn't established itself as being 
> valuable.... It is an interesting idea but I believe it that it would clutter 
> the module, slightly drowning-out the ABCs that have more broad and 
> established utility.

But based on this rationale, I would have thought Reversible wouldn't have been 
added. It was only after I found https://bugs.python.org/issue25987 the other 
day and saw that Reversible will be in 3.6 that I thought OrderedMapping had a 
case of similar strength, and so it seemed worth taking the time to try to 
contribute it for 3.7.

In any case, thanks again for your consideration, and if you have any further 
thoughts to share, it'd be much appreciated.

----------
nosy: +abarnert

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28912>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to