Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion performance of {} versus dict()
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chris Angelico  
View profile  
 More options Nov 14 2012, 6:42 pm
From: Chris Angelico <ros...@gmail.com>
Date: Thu, 15 Nov 2012 10:40:20 +1100
Local: Wed, Nov 14 2012 6:40 pm
Subject: Re: [Python-Dev] performance of {} versus dict()

On Thu, Nov 15, 2012 at 10:36 AM, Steven D'Aprano <st...@pearwood.info> wrote:
> On 15/11/12 05:54, Mark Adam wrote:

>> Merging of two dicts is done with dict.update.   How do you do it on
>> initialization?  This doesn't make sense.

> Frequently.

> my_prefs = dict(default_prefs, setting=True, another_setting=False)

> Notice that I'm not merging one dict into another, but merging two dicts
> into a third.

Side point: Wouldn't it be quite logical to support dict addition?

>>> {"a":1}+{"b":2}

Traceback (most recent call last):
  File "<pyshell#59>", line 1, in <module>
    {"a":1}+{"b":2}
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'

It would make sense for this to result in {"a":1,"b":2}.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-...@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/dev-python%2Bgarchi...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.