Connecting a long list to a c# component

Dear List,
I am working on a c# script which need to take input from a long list of integers. As shown in the image, I just connected a list to an empty c# component, nothing to compute as the component is empty. It still takes almost 1.3 minutes just to connect the list to the component.

I also tried another c# component with a boolean input to control running of all code. If i keep the boolean False so not code will run. If I connect the long list to the c# component, it also takes long time.

Could someone suggest what happened during this 1.3 minutes?

Every component run has a small amount of overhead — it doesn’t just run the code in your method. I suspect your input is still set to “Item Access” - meaning the component will run (even absent solution code) once for every item in the list. See if changing it to “List Access” makes things a bit faster - this should mean the component only runs once.

also just for the sake of my own curiosity, what on earth are you doing with a series going up to 20 million?


Hi Andrew,

Thank you for your reply. I did use list access and I realised the problem is Type hint. If I use int or double, then it is slow. If I keep it system.object then it is fast. Then I could cast it myself which is also fast.

For the 20 million input, I am using a ray tracer to test intersection of rays and meshes. It is reasonable fast, with 5000 sensors with 4000 directions = 20 million rays, it takes 18 seconds. Then I want to process the result list. This is when I found the c# component behave oddly.

ah yes, the type hint will make a big difference - the casting code is not particularly fast. It might seem counter-intuitive that double/int require a cast, but in fact the object coming out of a Series component is neither, it’s a GH_Number type, so casting is required.