On Tue, May 24, 2016 at 8:48 AM <[email protected]> wrote:

> ok i see, thanks Justin,
>
> so the extra stuff generated by code in a script, like strings, how can
> they be problematic or wasteful?, do you mean they just use up memory or
> slow things down? I dont think i fully understand where the stuff that is
> created is stored, and does it only dissappear when you restart maya?
>

Think of it like this:

a + b + c + d

tmp1 = a+b
tmp2 = tmp1 + c
tmp3 = tmp2 + d

Python has to allocate memory for a bunch of temporary strings as each pair
is concatenated. Then the garbage collector will reap them. That can mean
both wasted memory and slow performance. Consider if a,b,c,d were very
large strings. It would mean you would have to create large temporary
intermediate strings that get thrown away.

Now the behaviour of string concatenation using the + operator is
implementation specific, most likely. Meaning, it is up to the particular
python interpreter to decide how to evaluate it. It could be possible for
another type of python interpreter (or another version of the CPython
interpreter) to optimize the expression.

>
> thanks,
> Sam
>
> --
> 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/a1ef0c1c-9c39-486c-81ef-b99ab3745e80%40googlegroups.com
> .
> 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/CAPGFgA0nVDazSX5YH0srKCJShZZj4_pD1go4Ro_K0VmcJGaOxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to