[issue25987] collections.abc.Reversible

2016-04-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7d9f7d7a21ae by Georg Brandl in branch 'default':
#25987: add versionadded to Reversible.
https://hg.python.org/cpython/rev/7d9f7d7a21ae

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-04-17 Thread Guido van Rossum

Guido van Rossum added the comment:

Because it's a change to collections.abc, it goes in 3.6 only.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-04-17 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

I see that I forgot to include .. versionadded:: in the documentation.
Will this go into 3.5.2 or in 3.6?

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

Done. Thanks!

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-04-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 07f73360ea8e by Guido van Rossum in branch 'default':
Add collections.Reversible. Patch by Ivan Levkivskyi. Fixes issue #25987.
https://hg.python.org/cpython/rev/07f73360ea8e

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-04-04 Thread Guido van Rossum

Guido van Rossum added the comment:

Looks good. I'll merge this in a sec.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-04-02 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

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).

Please review.

PS: Some tests was skipped on my machine, here is the list:
test_bz2 test_curses test_dbm_gnu test_dbm_ndbm test_devpoll
test_idle test_kqueue test_lzma test_msilib test_ossaudiodev
test_smtpnet test_socketserver test_ssl test_startfile test_tcl
test_timeout test_tix test_tk test_ttk_guionly test_ttk_textonly
test_urllib2net test_urllibnet test_winreg test_winsound
test_xmlrpc_net test_zipfile64

--
keywords: +patch
Added file: http://bugs.python.org/file42357/reversible.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-03-26 Thread Ivan Levkivskyi

Changes by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-03-25 Thread Guido van Rossum

Guido van Rossum added the comment:

Andrew, did you lose interest in this? We now have a PR for typing.py that 
expects this to be resolved: https://github.com/python/typing/pull/194

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25987] collections.abc.Reversible

2016-01-01 Thread Andrew Barnert

New submission from Andrew Barnert:

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 
https://github.com/ambv/typehinting/issues/170 
(http://article.gmane.org/gmane.comp.python.ideas/37599):

> I also think it's fine to introduce Reversible as another ABC and carefully 
> fit it into the existing hierarchy. It should be a one-trick pony and be 
> another base class for Sequence; it should not have a default implementation. 
> (But this has been beaten to death in other threads -- it's time to just file 
> an issue with a patch.)

I'll file a patch this weekend. But in case there's anything to bikeshed, here 
are the details:

* Reversible is a subclass of Iterable.
 * It has a single abstract method, __reversed__, with no default 
implementation.
 * Its subclass hook that checks for __reversed__ existing and not being None.
* Sequence is a subclass of Reversible, Sized, and Container rather than 
directly of Iterable, Sized, and Container.

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 #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.

--
components: Library (Lib)
messages: 257310
nosy: abarnert
priority: normal
severity: normal
status: open
title: collections.abc.Reversible
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com