Comparison among Default GH Component, rhinocommon, rhinoscriptsyntax

Hi,

I’m currently learning how to use rhinoscriptsyntax and rhinocommon in Python.


Deconstruct Point Study.gh (21.6 KB)

I made these simple python scripts which work same as Deconstruct Point Component of GH. It returns coordinates of points. I attached the file.

I understand that rhinocommon is faster than rhinoscriptsyntax and the script which is using proper data structure is faster than which is not.

But what I’m curious about is that why rhinocommon, rhinoscriptsyntax script are much slower than Default Component of Gh, while they’re doing same thing?

Following is the fastest code I made using rhinocommon with proper data structure. P is a list of points.

x = []
y = []
z = []
for i in P:
    x.append(i.X)
    y.append(i.Y)
    z.append(i.Z)

X = x
Y = y
Z = z

Should I look at it in lower level how the function is operating?

Thanks.

These tips might help:

The native components are compiled C#. Which will likely always be faster than an IronPython implementation.

Edit: Here’s the result with no input type hint and using output type wrapping (which is largely the cost of the large loop i.e. with little input/output cost):

Deconstruct Point Study_AHD.gh (8.6 KB)

2 Likes

It’s the most perfect answer that I can get. It helps me a lot. Thanks a lot.

I’ve never heard of Grasshopper library and I’d never known if it weren’t for you.

Again, I appreciate it.

1 Like