Fast conversion from string to float in grasshopper

Hi there,

I am currently working on some relatively large wind simulation data analysis and visualization in GH and I am obviously fighting with several speed limits. One that I don’t seem able to get past though is the large hit I get when transforming strings to floats.
Converting just over 7M values takes way more than multiplying each of those with another float. Is there a clever trick/script/component that can help with that?

thanks a lot in advance,
Giovanni
image

Anyone?

That is not unexpected, as there is a fair amount of work involved in converting a string (that looks like a number) into an actual number.

My guess is GH is just calling Double.Parse or equivalent.

Gbetti.gh (3.5 KB)

– Dale

Yeah, plus the overhead for type inspection. You can get it somewhat faster if you know for a fact that all your text represents valid numbers:
conversion script.gh (10.0 KB) But the difference is not orders-of-magnitude.

Weirdly on GH2 the conversion from number to text is every bit as slow as in GH1, but from text to number it’s super fast. About two tenths of a second for 7 million values. Clearly it can be fast, so I need to look at where the bottlenecks still are.

2 Likes

Thanks David and Dave,

I’ll try this, especially because I know that is all just numbers.

18s instead of 1.4min is already appreciable!
Thanks for the support

Giovanni