[Python-Dev] performance of {} versus dict()
Mark Adam
dreamingforward at gmail.com
Wed Nov 14 18:08:32 CET 2012
On Wed, Nov 14, 2012 at 11:02 AM, Xavier Morel <python-dev at masklinn.net> wrote:
>
> On 2012-11-14, at 17:42 , Richard Oudkerk wrote:
>
>> On 14/11/2012 4:23pm, Serhiy Storchaka wrote:
>>> PEP 8 recommends:
>>>
>>> a_dict = dict(
>>> x=1,
>>> y=2,
>>> z=3,
>>> ...
>>> )
>>>
>>> and
>>>
>>> a_dict = {
>>> 'x': 1,
>>> 'y': 2,
>>> 'z': 3,
>>> ...
>>> }
>>
>> In which section? I can't see such a recommendation.
>
> Whitespace in Expressions and Statements > Other Recommendations
>
> 3rd bullet:
>
> —
> Don't use spaces around the = sign when used to indicate a keyword argument or a default parameter value.
>
> Yes:
>
> def complex(real, imag=0.0):
> return magic(r=real, i=imag)
>
> No:
>
> def complex(real, imag = 0.0):
> return magic(r = real, i = imag)
That's not a recommendation to use the **kwargs style.
mark
More information about the Python-Dev
mailing list