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 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, 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
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 +
>
> 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 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
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 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
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
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
>
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
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
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
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
>
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
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.
___
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:
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
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
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
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)
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
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
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
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
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
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
>
> 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 =
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
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 +=
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
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
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
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 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 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
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
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 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 +
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 +
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
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
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,
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: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
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 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?
>
>
50 matches
Mail list logo