[Python-Dev] performance of {} versus dict()

Brandon W Maister bwmaister at gmail.com
Wed Nov 14 22:40:37 CET 2012


>
> To (mis-)quote Antoine:
> >--> d1 = {1:2}
> >--> d2 = {'3':4}
> >--> dict(d1, **d2)
> > {1: 2, '3': 4}
>
> Apparently it is valid syntax.  Just make sure you keys for the **
> operator are valid strings.  :)
>
>
or not:

>>> dict(**{'not a valid identifier': True, 1: True})
{1: True, 'not a valid identifier': True}

brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121114/41b790a0/attachment.html>


More information about the Python-Dev mailing list