On Wed, 20 Mar 2019 15:46:24 -1000
Christopher Barker
wrote:
>
> > This is precisely why I worded my question this way: what has changed
> > in the last 20 years that make a "+" dict operator more compelling
> > today than it was? Do we merge dicts much more frequently than we
> > did?
>
> Th
On Thu, Mar 21, 2019 at 10:35 PM Antoine Pitrou wrote:
> > but it's NOT a new operator, it is making use of an existing one, and sure
> > you could guess at a couple meanings, but the merge one is probably one of
> > the most obvious to guess, and one quick test and you know -- I really
> > can't
On Thu, 21 Mar 2019 23:35:36 +1100
Chris Angelico wrote:
> On Thu, Mar 21, 2019 at 10:35 PM Antoine Pitrou wrote:
> > > but it's NOT a new operator, it is making use of an existing one, and sure
> > > you could guess at a couple meanings, but the merge one is probably one of
> > > the most obviou
On Thu, Mar 21, 2019 at 11:45 PM Antoine Pitrou wrote:
>
> On Thu, 21 Mar 2019 23:35:36 +1100
> Chris Angelico wrote:
> > On Thu, Mar 21, 2019 at 10:35 PM Antoine Pitrou wrote:
> > > > but it's NOT a new operator, it is making use of an existing one, and
> > > > sure
> > > > you could guess at
On Thu, 21 Mar 2019 23:51:12 +1100
Chris Angelico wrote:
> On Thu, Mar 21, 2019 at 11:45 PM Antoine Pitrou wrote:
> >
> > On Thu, 21 Mar 2019 23:35:36 +1100
> > Chris Angelico wrote:
> > > On Thu, Mar 21, 2019 at 10:35 PM Antoine Pitrou
> > > wrote:
> > > > > but it's NOT a new operator, i
21.03.19 14:51, Chris Angelico пише:
... then, in the interests of productive discussion, could you please
explain? What is it about dict addition that makes it harder to
understand than other addition?
Currently the + operator has 2 meanings for builtin types (both are
widely used), after add
On 21/03/2019 11:34, Antoine Pitrou wrote:
On Wed, 20 Mar 2019 15:46:24 -1000
Christopher Barker
wrote:
This is precisely why I worded my question this way: what has changed
in the last 20 years that make a "+" dict operator more compelling
today than it was? Do we merge dicts much more freq
On Fri, Mar 22, 2019 at 12:17 AM Serhiy Storchaka wrote:
>
> 21.03.19 14:51, Chris Angelico пише:
> > ... then, in the interests of productive discussion, could you please
> > explain? What is it about dict addition that makes it harder to
> > understand than other addition?
>
> Currently the + op
On Thu, Mar 21, 2019 at 9:17 AM Serhiy Storchaka
wrote:
> 21.03.19 14:51, Chris Angelico пише:
> > ... then, in the interests of productive discussion, could you please
> > explain? What is it about dict addition that makes it harder to
> > understand than other addition?
>
> Currently the + oper
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
> h
21.03.19 15:24, Chris Angelico пише:
On Fri, Mar 22, 2019 at 12:17 AM Serhiy Storchaka wrote:
21.03.19 14:51, Chris Angelico пише:
... then, in the interests of productive discussion, could you please
explain? What is it about dict addition that makes it harder to
understand than other additi
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 fu
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 mai
On Thu, Mar 21, 2019 at 03:16:44PM +0200, Serhiy Storchaka wrote:
> 21.03.19 14:51, Chris Angelico пише:
> >... then, in the interests of productive discussion, could you please
> >explain? What is it about dict addition that makes it harder to
> >understand than other addition?
>
> Currently the
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 in-pl
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 in-pla
I'd like to make a plea to people:
I get it, there is now significant opposition to using the + symbol for
this proposed operator. At the time I wrote the first draft of the PEP,
there was virtually no opposition to it, and the | operator had very
little support. This has clearly changed.
At t
On Fri, 22 Mar 2019 03:42:00 +1100
Steven D'Aprano wrote:
>
> For those who oppose the + operator, it will help me if you made it
> clear whether it is *just* the + symbol you dislike, and would accept
> the | operator instead, or whether you hate the whole operator concept
> regardless of how
Le 21 mars 2019 à 17:43:31, Steven D'Aprano
(st...@pearwood.info(mailto:st...@pearwood.info)) a écrit:
> I'd like to make a plea to people:
>
> I get it, there is now significant opposition to using the + symbol for
> this proposed operator. At the time I wrote the first draft of the PEP,
> there
Steven D'Aprano wrote:
> But if you have *concrete examples* of code that currently is easy to
> understand, but will be harder to understand if we add dict.__add__,
> then please do show me!
# What does this do?
>>> items. update(points)
# And what does this do?
>>> items += po
On Thu, 21 Mar 2019 at 17:27, Rémi Lapeyre wrote:
>
> Le 21 mars 2019 à 17:43:31, Steven D'Aprano
> (st...@pearwood.info(mailto:st...@pearwood.info)) a écrit:
>
> > I'd like to make a plea to people:
> >
> > I get it, there is now significant opposition to using the + symbol for
> > this proposed
>
> And to those who support this PEP, code examples where a dict merge
> operator will help are most welcome!
I would definitely include the example you alluded to in the operators
thread:
Before:
tmp = keep.copy()
tmp.update(separate)
result = function(param=tmp)
del tmp
After:
result = f(p
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 strong
Rémi Lapeyre wrote:
> Not matter the notation you end up choosing, I think this code:
> https://github.com/jpadilla/pyjwt/blob/master/jwt/utils.py#L71-L81
> [...] would greatly benefit from a new merge to merge dicts.
I've looked at the merge_dict defined in this code. It's similar to
def ga
Brandt Bucher wrote:
> Before:
>
> tmp = keep.copy()
> tmp.update(separate)
> result = function(param=tmp)
> del tmp
> After:
>
> result = f(param=keep+separate)
I'd rewrite this example as:
Before:
fn(param={**keep, **separate})
After:
fn(param=keep + separate)
--
Jonathan
_
Chris Angelico writes:
> ... then, in the interests of productive discussion, could you please
> explain? What is it about dict addition that makes it harder to
> understand than other addition?
Antoine didn't say what dict addition does is harder to understand
than other addition. He said he
On 3/21/19 1:01 PM, Jonathan Fine wrote:
Rémi Lapeyre wrote:
Not matter the notation you end up choosing, I think this code:
https://github.com/jpadilla/pyjwt/blob/master/jwt/utils.py#L71-L81
[...] would greatly benefit from a new merge to merge dicts.
I've looked at the merge_dict defined in
On 21/03/2019 17:06, Antoine Pitrou wrote:
On Fri, 22 Mar 2019 03:42:00 +1100
Steven D'Aprano wrote:
For those who oppose the + operator, it will help me if you made it
clear whether it is *just* the + symbol you dislike, and would accept
the | operator instead, or whether you hate the whole o
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) fir
I'd also like to add what I consider to be another point in favor of an
operator:
Throughout all of these related threads, I have seen many typos and
misspellings of current dict merging idioms, from messing up the number of
asterisks in "{**a, **b}", to even Guido(!) accidentally writing the comm
On 21/03/2019 17:59, Rhodri James wrote:
def process():
if time_to_do_thing1():
thing1(base_env + thing1_env_stuff + env_tweaks)
if time_to_do_thing2():
thing2(base_env + thing2_env_stuff + env_tweaks)
...and so on. The current syntax for doing this is a tad verbose:
On Thu, 21 Mar 2019 17:59:41 +
Rhodri James wrote:
>
> >> And to those who support this PEP, code examples where a dict merge
> >> operator will help are most welcome!
>
> I don't use Python often enough to have much to offer, I'm afraid. The
> sort of occasion I would use dict merging i
Hello,
Can you please help me to contact a core team if it is possible.
I would like to report an issue.
Thank you,
Hardik Patel
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: h
Hello,
On Thu, 21 Mar 2019 15:31:30 -0400
Hardik Patel
wrote:
> Hello,
> Can you please help me to contact a core team if it is possible.
> I would like to report an issue.
Issues can be reported at https://bugs.python.org/
Regards
Antoine.
___
P
Antoine Pitrou wrote:
> Note that, if you're able to live with a third-party dependency, the
> `toolz` package has what you need (and lots of other things too):
> https://toolz.readthedocs.io/en/latest/api.html#toolz.dicttoolz.merge
I suggest that the supporters of dict + dict make (and put up on
On Fri, Mar 22, 2019 at 8:44 AM Jonathan Fine wrote:
>
> Antoine Pitrou wrote:
> > Note that, if you're able to live with a third-party dependency, the
> > `toolz` package has what you need (and lots of other things too):
> > https://toolz.readthedocs.io/en/latest/api.html#toolz.dicttoolz.merge
>
I dislike the symbol '+' to mean "dictionary merging with value updates." I
have no objection to, and mildly support, adding '|' with this meaning.
It's not really possible to give "that one example" where + for meeting
makes code less clear... In my eyes it would be EVERY such use. Every
example
For anyone interested in "trying it out": if you're not against cloning and
compiling CPython yourself, here is a PEP 584 C implementation I have PR'd
against master right now. I'm keeping it in sync with the draft PEP as it
changes, so subtraction performance is not overly optimized yet, but it
wi
On Fri, Mar 22, 2019 at 3:42 AM Steven D'Aprano wrote:
> And to those who support this PEP, code examples where a dict merge
> operator will help are most welcome!
Since Python examples don't really exist yet, I'm reaching for another
language that DOES have this feature. Pike's mappings (broadly
On Thu, Mar 21, 2019 at 06:02:05PM -0400, David Mertz wrote:
> I dislike the symbol '+' to mean "dictionary merging with value updates." I
> have no objection to, and mildly support, adding '|' with this meaning.
>
> It's not really possible to give "that one example" where + for meeting
> makes c
On Thu, Mar 21, 2019 at 03:10:48PM -0700, Brandt Bucher wrote:
> For anyone interested in "trying it out": if you're not against cloning and
> compiling CPython yourself, here is a PEP 584 C implementation I have PR'd
> against master right now. I'm keeping it in sync with the draft PEP as it
> cha
On Thu, Mar 21, 2019, 7:48 PM Steven D'Aprano wrote:
> A number of people including Antoine and Serhiy seem to have taken the
> position that merely adding dict.__add__ will make existing code using +
> harder to understand, as you will need to consider not just numeric
> addition and concatenati
On 3/21/19 6:46 PM, Steven D'Aprano wrote:
Antoine and Serhiy seem to worry that there are existing uses of + which
are currently easy to understand but will become less so if dict.__add__
is added. I respect that worry, even if I doubt that they are correct.
If someone can demonstrate that the
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, imm
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 w
On Thu, Mar 21, 2019 at 08:13:01PM -0400, David Mertz wrote:
> On Thu, Mar 21, 2019, 7:48 PM Steven D'Aprano wrote:
[...]
> Nonetheless, if I see `dict1 + dict2` the meaning you intend in the PEP
> does not jump out as the obvious behavior. Nor even as the most useful
> behavior.
What would be
>
> https://docs.python.org/3.8/library/collections.html has some
> examples using collections.Counter, which is clearly described
> as being a subclass of dict. Amongst the examples:
>
> c + d # add two counters together: c[x] + d[x]
>
> That's the + operator operating on two dicts (don't
On 3/21/19 9:19 PM, Christopher Barker wrote:
https://docs.python.org/3.8/library/collections.html has some
examples using collections.Counter, which is clearly described
as being a subclass of dict. Amongst the examples:
c + d # add two counters together: c[x] + d[x]
That's the + oper
On Thu, Mar 21, 2019, 10:15 PM Steven D'Aprano wrote:
> What would be the most useful behaviour for dict "addition" in your
> opinion?
>
Probably what I would use most often was a "lossless" merging in which
duplicate keys resulted in the corresponding value becoming a set
containing all the mer
On 2019-03-22 02:40, Dan Sommers wrote:
On 3/21/19 9:19 PM, Christopher Barker wrote:
https://docs.python.org/3.8/library/collections.html has some
examples using collections.Counter, which is clearly described
as being a subclass of dict. Amongst the examples:
c + d # add two counters
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 what
51 matches
Mail list logo