[Python-Dev] Add reversed methods for dict (original) (raw)
Victor Stinner vstinner at redhat.com
Fri May 25 11:53:58 EDT 2018
- Previous message (by thread): [Python-Dev] Add __reversed__ methods for dict
- Next message (by thread): [Python-Dev] Add __reversed__ methods for dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
INADA Naoki asked Rémi Lapeyre in https://bugs.python.org/issue33462 to start a discussion on python-dev.
Victor
2018-05-25 17:48 GMT+02:00 Guido van Rossum <guido at python.org>:
(Also this probably belongs in python-ideas, unless there's already a bugs.python.org issue for it -- but you didn't mention that so I assume it's just an idea? How did you reach the line count estimates?)
On Fri, May 25, 2018 at 8:46 AM, Guido van Rossum <guido at python.org> wrote:
Please go find some real world code that would benefit from this. Don't make up examples, just show some code in a repository (public if possible, but private is okay, as long as you can quote small amounts of code from it) where te existence of reverse iteration over a dict would have been helpful. On Thu, May 24, 2018 at 5:55 AM, Rémi Lapeyre <remi.lapeyre at vint.fr> wrote:
Hi, since dict keys are sorted by their insertion order since Python 3.6 and that it’s part of Python specs since 3.7 a proposal has been made in bpo-33462 to add the reversed method to dict and dict views. Concerns have been raised in the comments that this feature may add too much bloat in the core interpreter and be harmful for other Python implementations. Given the different issues this change creates, I see three possibilities: 1. Accept the proposal has it is for dict and dict views, this would add about 300 lines and three new types in dictobject.c 2. Accept the proposal only for dict, this would add about 80 lines and one new type in dictobject.c while still being useful for some use cases 3. Drop the proposal as the whole, while having some use, reversed(dict(a=1, b=2)) may not be very common and could be done using OrderedDict instead. What’s your stance on the issue ? Best regards, Rémi Lapeyre
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido) -- --Guido van Rossum (python.org/~guido)
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/vstinner%40redhat.com
- Previous message (by thread): [Python-Dev] Add __reversed__ methods for dict
- Next message (by thread): [Python-Dev] Add __reversed__ methods for dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]