Animation Nodes Loop Input performance issue with large 3d vectors numpy arrays I am working on scientific visualizations involving huge arrays of 3d vectors, sometimes 100k or sometimes even millions of vectors. I quickly ran into performance related issues, mostly when needing to iterate over arrays of vectors, or even values, using Loop Inputs.
Case in point, the attached blend file, that &quot;spiralizes&quot; a linear segment. I generate an 1D array of numpy values between a and b using:
interpolated_values = np.linspace(value_a,value_b,number_of_elements)
and I invoke that in a 3d vector combine node in x and rotate every vector in the array around it's Z-axis using a multiplied value of it's own index. In order to do that I have to iterate over the array using a Loop Input node. So far so good, it works, but the performance is a killer. Already by 1k iterations the scene lags like crazy on a quite powerful machine. Comparatively, if I do exactly the same in XSI's ICE, I can generate over 100k vectors before the scene starts lagging.
Is there a better way to achieve this than using Loop Input, which is the culprit here? Using a for loop in Python doesn't work of course, as the for loop is first executed in the script and then called in AN...
Here is the attached blend file https://we.tl/t-L8snsm1VOE
I think it is executing the script node every iteration so I added a float list parameter to the loop and put your script node outside of the loop. On my machine instead of about 350ms execution time I got about 50ms execution time with it outside. about 7 times improvement.