Scripts are not faster than expression at execution.
But an expression executes at each frame.
The script only executes one time, when you ask it to.
An expression equal in code with a script is like running that script for each frame.
I didn’t know Math is slow.
I know that it is very slow to link another property that links to another property and so on(recursively).
Ex: if you put some layers one under the other, with some expression like thisComp.layer(index-1).position+[0,20], each time you add another layer, things complicate in an exponential manner. Because each layer calculates all the previous layers, since expressions don’t save the value. I don’t know if they optimized this in the latest versions(19-20), but this was a pain before.
There are also the ones that calculate multiple values you had before in the composition, using valueAtTime() in some loops. The longer the composition, the more it takes for each frame to render.
Turning to keyframes is a bit similar to scripts. When using “Convert Expression to Keyframes” you calculate the expressions, and then save the results. No more calculation when rendering.
If anyone has more information, like what is super slow, of how can you measure the speed of your expressions, I would also love to hear.
Andrei
My Envato portfolio.