Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee = None closed_at = <Date 2016-04-04.18:00:23.026> created_at = <Date 2016-01-01.22:00:33.076> labels = ['type-feature', 'library', 'docs'] title = 'collections.abc.Reversible' updated_at = <Date 2016-04-18.05:26:11.865> user = 'https://bugs.python.org/abarnert'
activity = <Date 2016-04-18.05:26:11.865> actor = 'python-dev' assignee = 'docs@python' closed = True closed_date = <Date 2016-04-04.18:00:23.026> closer = 'gvanrossum' components = ['Documentation', 'Library (Lib)'] creation = <Date 2016-01-01.22:00:33.076> creator = 'abarnert' dependencies =  files = ['42357'] hgrepos =  issue_num = 25987 keywords = ['patch'] message_count = 10.0 messages = ['257310', '257488', '262481', '262800', '262858', '262859', '262860', '263614', '263636', '263642'] nosy_count = 5.0 nosy_names = ['gvanrossum', 'docs@python', 'python-dev', 'abarnert', 'levkivskyi'] pr_nums =  priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue25987' versions = 
The text was updated successfully, but these errors were encountered:
This came up as a side issue in the -ideas discussion on deprecating the old-style sequence protocol that came out of Guido's suggestion on python/typing#170 (http://article.gmane.org/gmane.comp.python.ideas/37599):
I'll file a patch this weekend. But in case there's anything to bikeshed, here are the details:
Builtins tuple and list, and any subclasses of them, will be Reversible because they register with Sequence or MutableSequence. Subclasses of collections.abc.Sequence will be Reversible (and should be, as they inherit Sequence.__reversed__). Custom old-style sequences will not be Reversible, even though reversed works on them.
Builtins dict, set, and frozenset, and any subclasses of them, will not be Reversible (unless they add a __reversed__ method, as OrderedDict does). Subclasses of collections.abc.Mapping will not be Reversible (and should not be, as, assuming bpo-25864 goes through, they inherit Mapping.__reversed__=None) (unless they add a __reversed__ method, as most third-party sorted-dict types do).
I'll include tests for all of those things.
I believe this is all exactly parallel with collections.abc.Iterable, and will make collections.abc.Reversible compatible with typing.Reversible[...] in exactly the same way collections.abc.Iterable is compatible with typing.Iterable[...].
Alternatives: We could make Reversible independent of Iterable. Alternatively, we could make it subclass both Iterable and Sized instead of just Iterable. But I think this is the simplest place to slot it in.
I was not sure whether Andrew is still interested. I made a simple-minded patch following his proposal. I also added tests and changed docs accordingly. Note that I also changed the expected MRO for MutableSequence in one of the functools tests according to the new hierarchy (otherwise test_functools fails).
PS: Some tests was skipped on my machine, here is the list: