23.03.19 18:24, Christopher Barker пише:
I wonder how often + is used with lists in the stdlib...
Searching for "+ [" shows that even concatenating with the string
display and comprehensions is several times more common that merging
dicts. And there should be cases not covered by this simple
> > I think that's a good indication that there are uses for a merge
> > operator.
>
> Some, yes. Enough for new syntax?
Let’s be clear here — this would not be new syntax — the operator (s)
already exist and are commonly used and overloaded already. This would be a
minor change to the
On 3/22/2019 12:53 AM, Steven D'Aprano wrote:
On Thu, Mar 21, 2019 at 09:36:20PM -0400, Terry Reedy wrote:
I counted what I believe to be 10 instances of copy-update in the top
level of /lib. Do either of you consider this to be enough that any
addition would be worthwhile.
I think you're
On Thu, Mar 21, 2019 at 09:36:20PM -0400, Terry Reedy wrote:
> I counted what I believe to be 10 instances of copy-update in the top
> level of /lib. Do either of you consider this to be enough that any
> addition would be worthwhile.
I think you're referring to Guido and Antoine? But for
On Fri, Mar 22, 2019 at 1:21 AM Steven D'Aprano wrote:
>
>
> How about dict.merged(*args, **kw)? Or dict.updated()?
>
+1 on "merged".
I feel the word "update" indicating mutating, and it's difficult to distinguish
between "update" and "updated".
> That would eliminate some of the difficulties
On 3/21/2019 12:11 PM, Guido van Rossum wrote:
On Thu, Mar 21, 2019 at 7:45 AM Antoine Pitrou
One should also be able to write `d = dict.merge(d1, d2, ...)`
If dict merging is important enough to get a new spelling, then I think
this proposal is the best: explicit, unambiguous,
On Thu, Mar 21, 2019 at 1:54 PM Stefan Behnel wrote:
> Steven D'Aprano schrieb am 21.03.19 um 17:21:
> > On Thu, Mar 21, 2019 at 09:11:18AM -0700, Guido van Rossum wrote:
> >
> >> I don't find it easy to understand or remember that d1.update(d2)
> modifies
> >> d1 in place, while d1.merge(d2)
Steven D'Aprano schrieb am 21.03.19 um 17:21:
> On Thu, Mar 21, 2019 at 09:11:18AM -0700, Guido van Rossum wrote:
>
>> I don't find it easy to understand or remember that d1.update(d2) modifies
>> d1 in place, while d1.merge(d2) first copies d1.
>>
>> Maybe the name can indicate the copying
On Thu, Mar 21, 2019 at 09:11:18AM -0700, Guido van Rossum wrote:
> I don't find it easy to understand or remember that d1.update(d2) modifies
> d1 in place, while d1.merge(d2) first copies d1.
>
> Maybe the name can indicate the copying stronger? Like we did with sorting:
> l.sort() sorts
On Thu, Mar 21, 2019 at 09:11:18AM -0700, Guido van Rossum
wrote:
> I don't find it easy to understand or remember that d1.update(d2) modifies
> d1 in place, while d1.merge(d2) first copies d1.
>
> Maybe the name can indicate the copying stronger? Like we did with sorting:
> l.sort() sorts
On 2019-03-21 17:11, Guido van Rossum wrote:
I don't find it easy to understand or remember that d1.update(d2)
modifies d1 in place, while d1.merge(d2) first copies d1.
That would be an advantage with + versus += (or | versus |=).
___
Python-ideas
On Thu, Mar 21, 2019 at 7:45 AM Antoine Pitrou wrote:
> On Tue, 5 Mar 2019 16:39:40 +0900
> INADA Naoki
> wrote:
> > I think some people in favor of PEP 584 just want
> > single expression for merging dicts without in-place update.
> >
> > But I feel it's abuse of operator overload. I think
On Tue, 5 Mar 2019 16:39:40 +0900
INADA Naoki
wrote:
> I think some people in favor of PEP 584 just want
> single expression for merging dicts without in-place update.
>
> But I feel it's abuse of operator overload. I think functions
> and methods are better than operator unless the operator
>
On Tue, Mar 5, 2019 at 7:59 PM Steven D'Aprano wrote:
>
> On Tue, Mar 05, 2019 at 06:04:40PM +0900, INADA Naoki wrote:
> [...]
> > One obvious merit of d.merge(...) is it returns same type of d.
> > `type(d1)(d1, d2)` looks ugly.
> >
> > But people just want dict instead of some subtype of dict.
On Tue, Mar 05, 2019 at 06:04:40PM +0900, INADA Naoki wrote:
[...]
> One obvious merit of d.merge(...) is it returns same type of d.
> `type(d1)(d1, d2)` looks ugly.
>
> But people just want dict instead of some subtype of dict.
> This merit is not so important.
Not to me! It *is* important to
Python C API has PyDict_Merge
(https://docs.python.org/3/c-api/dict.html#c.PyDict_Merge) function
which has different behavior than the proposed Python level method
(doesn't copy but merge in-place).
This is a red flag for me.
On Tue, Mar 5, 2019 at 12:24 PM fhsxfhsx wrote:
>
> I agree so much
I agree so much on your opinion that I was just to create a topic about this if
you didn't.
I also propose here a small modification to make it more general which adds an
argument `how` (name to be discussed), telling how to merge the dicts, as many
have pointed out that there could be
> * Type of returned value is always same to d1.copy(). No issubclass,
> no __iadd__.
I'm sorry, I meant __radd__, not __iadd__.
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of
On Tue, Mar 5, 2019 at 5:50 PM Nathaniel Smith wrote:
>
> On Mon, Mar 4, 2019 at 11:41 PM INADA Naoki wrote:
> > Then, I propose `dict.merge` method. It is outer-place version
> > of `dict.update`, but accepts multiple dicts. (dict.update()
> > can be updated to accept multiple dicts, but it's
On Mon, Mar 4, 2019 at 11:41 PM INADA Naoki wrote:
> Then, I propose `dict.merge` method. It is outer-place version
> of `dict.update`, but accepts multiple dicts. (dict.update()
> can be updated to accept multiple dicts, but it's not out of scope).
>
> * d = d1.merge(d2) # d = d1.copy();
On Tue, Mar 5, 2019 at 5:23 PM Chris Angelico wrote:
>
> On Tue, Mar 5, 2019 at 6:40 PM INADA Naoki wrote:
> > This is why function and methods are better:
> >
> > * Easy to search.
> >
> > ## Merits of dict.merge() over operator +
> >
> > * Easy to Google (e.g. "python dict merge").
>
> This
On Tue, Mar 5, 2019 at 6:40 PM INADA Naoki wrote:
> This is why function and methods are better:
>
> * Easy to search.
>
> ## Merits of dict.merge() over operator +
>
> * Easy to Google (e.g. "python dict merge").
This keeps getting thrown around. It's simply not true.
I think some people in favor of PEP 584 just want
single expression for merging dicts without in-place update.
But I feel it's abuse of operator overload. I think functions
and methods are better than operator unless the operator
has good math metaphor, or very frequently used as concatenate
23 matches
Mail list logo