Re: [Python-Dev] Add __reversed__ methods for dict

2018-06-08 Thread Guido van Rossum
That sounds right to me. We will then have had two versions where this was the case: - 3.6 where order preserving was implemented in CPython but in the language spec - 3.7 where it was also added to the language spec On Fri, Jun 8, 2018 at 11:05 AM, Michael Selik wrote: > Am I correct in saying

Re: [Python-Dev] Add __reversed__ methods for dict

2018-06-08 Thread Michael Selik
Am I correct in saying that the consensus is +1 for inclusion in v3.8? The last point in the thread was INADA Naoki researching various implementations and deciding that it's OK to include this feature in 3.8. As I understand it, Guido was in agreement with INADA's advice to wait for

Re: [Python-Dev] Add __reversed__ methods for dict

2018-06-02 Thread Armin Rigo
Hi Inada, On 27 May 2018 at 09:12, INADA Naoki wrote: > When focusing to CPython, PyPy and MicroPython, no problem for adding > __reverse__ in 3.8 seems OK. Fwiw, the functionality that is present in OrderedDict but still absent from 'dict' is: ``__reverse__``, discussed above, and

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-27 Thread INADA Naoki
On Sun, May 27, 2018 at 12:43 PM Raymond Hettinger < raymond.hettin...@gmail.com> wrote: > > On May 26, 2018, at 7:20 AM, INADA Naoki wrote: > > > > Because doubly linked list is very memory inefficient, every implementation > > would be forced to implement dict like

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-26 Thread Raymond Hettinger
> On May 26, 2018, at 7:20 AM, INADA Naoki wrote: > > Because doubly linked list is very memory inefficient, every implementation > would be forced to implement dict like PyPy (and CPython) for efficiency. > But I don't know much about current MicroPython and other

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-26 Thread Guido van Rossum
Hm, I find Inada's argument compelling that this might not be easy for all implementations. So let's wait. On Sat, May 26, 2018 at 7:20 AM, INADA Naoki wrote: > > Concerns have been raised in the comments that this feature may add too > much > > bloat in the core

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-26 Thread INADA Naoki
> 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. To clarify, my point is it prohibit hashmap + single linked list implementation in other Python implementation. Because doubly linked

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Ramsey D'silva
I am also in agreement. On Fri, May 25, 2018, 13:49 Guido van Rossum wrote: > OK, +1 > > On Fri, May 25, 2018 at 10:26 AM, Raymond Hettinger < > raymond.hettin...@gmail.com> wrote: > >> >> >> > On May 25, 2018, at 9:32 AM, Antoine Pitrou >> wrote: >> > >>

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Guido van Rossum
OK, +1 On Fri, May 25, 2018 at 10:26 AM, Raymond Hettinger < raymond.hettin...@gmail.com> wrote: > > > > On May 25, 2018, at 9:32 AM, Antoine Pitrou wrote: > > > > It's worth nothing that OrderedDict already supports reversed(). > > The argument could go both ways: > > > >

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Raymond Hettinger
> On May 25, 2018, at 9:32 AM, Antoine Pitrou wrote: > > It's worth nothing that OrderedDict already supports reversed(). > The argument could go both ways: > > 1. dict is similar to OrderedDict nowadays, so it should support > reversed() too; > > 2. you can use

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Antoine Pitrou
It's worth nothing that OrderedDict already supports reversed(). The argument could go both ways: 1. dict is similar to OrderedDict nowadays, so it should support reversed() too; 2. you can use OrderedDict to signal explicitly that you care about ordering; no need to add anything to dict.

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Victor Stinner
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 : > (Also this probably belongs in python-ideas, unless there's already a > bugs.python.org issue for it -- but you

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Victor Stinner
It looks like an optimization, since you can already do something like reversed(list(d)). Do you have benchmark numbers to see the benefit of your change? Even if reversed(list(d)) is slow, I'm not sure that it's worth it to optimize it, since it's a rare usecase. Victor 2018-05-24 14:55

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Guido van Rossum
(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 wrote: > Please go

Re: [Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Guido van Rossum
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

[Python-Dev] Add __reversed__ methods for dict

2018-05-25 Thread Rémi Lapeyre
  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