[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Jim Baker
-1 on this new functionality Referring again to PEP 3106, and its support for views - this was inspired by the functionality seen with java.util.Map. Now that dict is sort of like java.util.LinkedHashMap - albeit safe for concurrent operations* - it's worth exploring if there's anything in the exp

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Dominik Vilsmeier
On 07.07.20 19:41, Stephen J. Turnbull wrote: Dominik Vilsmeier writes: > Well, the point is that this "except comparisons" is not quite true: > >     >>> i = {'a': []}.items() >     >>> s = {('a', 1)} >     >>> i == s >     TypeError: unhashable type: 'list' > > If passed a

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Dominik Vilsmeier
On 07.07.20 19:09, Christopher Barker wrote: On Tue, Jul 7, 2020 at 6:56 AM Dominik Vilsmeier mailto:dominik.vilsme...@gmx.de>> wrote: Well, the point is that this "except comparisons" is not quite true: >>> i = {'a': []}.items() >>> s = {('a', 1)} >>> i == s

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Dominik Vilsmeier
On 07.07.20 17:37, Inada Naoki wrote: On Tue, Jul 7, 2020 at 10:52 PM Dominik Vilsmeier wrote: Surely that must be a relic from pre-3.7 days where dicts were unordered and hence order-based comparison wouldn't be possible (though PEP 3106 describes an O(n*m) algorithm). However the current beh

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Stephen J. Turnbull
Dominik Vilsmeier writes: > Well, the point is that this "except comparisons" is not quite true: > >     >>> i = {'a': []}.items() >     >>> s = {('a', 1)} >     >>> i == s >     TypeError: unhashable type: 'list' > > If passed a set as `other` operand, dict_items seems to decide to

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Christopher Barker
On Tue, Jul 7, 2020 at 6:56 AM Dominik Vilsmeier wrote: > Well, the point is that this "except comparisons" is not quite true: > > >>> i = {'a': []}.items() > >>> s = {('a', 1)} > >>> i == s > TypeError: unhashable type: 'list' > > If passed a set as `other` operand, dict_item

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Inada Naoki
On Tue, Jul 7, 2020 at 10:52 PM Dominik Vilsmeier wrote: > > Surely that must be a relic from pre-3.7 days where dicts were unordered > and hence order-based comparison wouldn't be possible (though PEP 3106 > describes an O(n*m) algorithm). However the current behavior is > unfortunate because it

[Python-ideas] functools.partial not freezing the keyword arguments

2020-07-07 Thread ndg1
The official doc of the partial function from the functools stdlib module says it "is used for partial function application which “freezes” some portion of a function’s arguments and/or keywords resulting in a new object with a simplified signature". However, whereas positional arguments are ef

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-07 Thread Dominik Vilsmeier
On 05.07.20 16:56, Stephen J. Turnbull wrote: Steven D'Aprano writes: > Regarding your observation that dict views behave poorly if they > have unhashable values, I agree, it is both odd and makes them less > useful. Possibly at some point between the PEP and the release of > the featur

[Python-ideas] Re: Add builtin function for min(max())

2020-07-07 Thread Rob Cliffe via Python-ideas
On 06/07/2020 10:44, Federico Salerno wrote: On 05/07/2020 23:55, Rob Cliffe wrote: I don't think the new function should be restricted to numbers.  There may be uses for strings, or for user-built classes; why restrict it unnecessarily? If it quacks like supporting __lt__ and __gt__, it's