Is there a way to speed up this python script?

I’ve been updating some big tables as part of my dynamo scripts and the run times are starting to bloat (30+ min). I’ve had some luck re-writing some nodes in python to improve performance but it actually seemed to get worse when I tried it with table.SetStringText. Is there a better way to update table values with dynamo? Thanks!

Wow, 30+ min? I’m not sure why you would get that kind of performance. Could you share an example .dwg and .dyn so I can look into it? Possibly something a bit more bite sized that won’t take a 30 minute run time just to test? :sweat_smile:

I’m linking the dwg and dyn script but I think, once you open the script, you’ll see how the execution time can get bloated. Even with all those nodes the vast majority of execution time is just updating the table itself. With two drainage areas it should take <5 min. But when you have a few dozen…

rdp_Update_Catchment_Table.dyn (331.1 KB)

Speaking of overly complicated scripts - I forgot to freeze all the ootb table update nodes. Once I did that performance improved immensely. I’m a bit embarrassed but at least I have an answer :sweat_smile:

I’m still interested to check it out :slight_smile: maybe I can find something to speed it up as well.

1 Like

I’m thankful for any insight you can provide! There’s so much to learn with Dynamo. I don’t even know why running the commands through a python script is faster than ootb nodes in the first place.

All nodes cache their results along the way (which is why you can see the output of each node), but that comes at the price of memory overhead. If you wrap up a whole sequence of steps in a Python node and only output the final result, then the memory overhead is reduced because the intermediate results are removed (aka garbage collected) along the way.

4 Likes

have you tried TuneUP ? You can see exactly what nodes are causing the problem. Its super useful when you want to increase your performance : TuneUp Extension: Explore your Node and Graph execution times - Dynamo BIM

Also, take a look at this community conversation with @jacob.small all about performance issues : 20 - How to Make Dynamo Sing! - YouTube

3 Likes