[openstack-dev] Use of local()

Mark McClain mark.mcclain at dreamhost.com
Fri Feb 8 15:15:30 UTC 2013


-1 on locals()

-1 on adding kwargs to OpenStack logging methods.  It's replacing one type of magic with another type.

It may not be perfect, but Python has a well established logging module.  When we make decisions to create custom variants of python internals with different method signatures we actually make this project harder for new developers to join.  We're also breaking one of the ideals of Python "There should be one-- and preferably only one --obvious way to do it."  This is from the Zen of Python (If you've never read it, start up the interpreter and type 'import this').  Having the option to pass a dict via the args param or using the proposed kwargs parameter violates this concept.

I also do not accept that dictionaries created in code have any readability impact when properly styled.  A method call with many keyword args is just as ugly.

There are also performance considerations about constructing dictionaries and I'd like to point everyone to Doug Hellman's written article  about dictionary construction performance.

http://www.doughellmann.com/articles/misc/dict-performance/index.html

mark

On Feb 8, 2013, at 7:02 AM, Sean Dague <sdague at linux.vnet.ibm.com> wrote:

> On 02/08/2013 12:13 AM, Jay Pipes wrote:
>> On 02/07/2013 09:58 PM, Sean Dague wrote:
>>> On 02/07/2013 06:04 PM, Nachi Ueno wrote:
>>>>> I suspect we should just slowly transition as people touch code.
>>>> 
>>>> I agree. The reason why I asked this is for reviewing.
>>>> so I'll comment not to use local() in review.
>>> 
>>> If we have rough concensus start with updating HACKING in the relevant
>>> projects. Then I suggest a grind through replacing the code. Once it's
>>> out we can enforce it in hacking.py (comming soon to a project near you,
>>> and not just in nova and tempest).
>> 
>> Go for it. Jason's suggestion for allowing LOG.debug() et al messages to
>> allow kwargs would make things much more readable than supplying huge
>> manually-coded dicts.
> 
> +1, that was a nice suggestion.
> 
> -- 
> Sean Dague
> IBM Linux Technology Center
> email: sdague at linux.vnet.ibm.com
> alt-email: sldague at us.ibm.com
> 
> 
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20130208/d4f5749d/attachment.html>


More information about the OpenStack-dev mailing list