On Tue, May 24, 2016 at 9:15 AM Marcus Ottosson <[email protected]>
wrote:

> Concatenating strings creates maple copies along the way, as each pair is
> concatenated and a new string is return for for the next addition.
>
> This is probably true, but come on. For performance?
>
> This..
>
> for light in all_lights:
>     light_intensity = cmds.getAttr(light + '.intensity')
>
> ..is a lot more readable than this..
>
> for light in all_lights:
>     light_intensity = cmds.getAttr('{0}.intensity'.format(light))
>
> And that makes it right.
>

Surprisingly, you stopped quoting me just before this bit:

"In small use cases it won't matter. But in loops and with tons of string
it would be wasteful. "

I specifically said that in small cases it doesn't matter. I was explaining
why there is a difference at in, given potential cases.

Readability counts. So, yes, do what is more readable and profile you code
to find out if you have hot spots...and don't take things out of context.


> ​
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCxFHER9TWi2QOa81uiB%3D73%3D3Ou3yMPO1woMBSUFzpj1Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCxFHER9TWi2QOa81uiB%3D73%3D3Ou3yMPO1woMBSUFzpj1Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3GQqxoRieWds89uP9GLo7xhNW%2BGZR4zYN%3DRS_Y-A1Kgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to