Compiled GHPY vs GhPython


  1. Processing-wise, which one is heavier a scripting component or compiled ghpy?
  2. Do all components become multi-threaded? (even .ghpy?)

Computational times are likely similar, maybe there’s a minor speedup with GHPY (just test it to know), loading time is longer for the GHPY, as it’s a new assembly to parse. The purpose of compilation is to provide the working data without the source code. It’s a facility provided by IronPython: clr.CompileModules().

No, this has nothing to do with multi-threading. The execution is unchanged, the same engine executes both.

Do I somehow need to program the ghpython, respectively the .ghpy to use multiple threads, or it switches if computation becomes too big?

As usual, you just need to program the multi-threaded code yourself.

Would it be unacceptable to request a Python example for that, too, @piac ?

I’m not changing any visual attributes :stuck_out_tongue:

1 Like

Hi @piac,

As far as I understand this multi-threading is about when completing several tasks inside the same script/ghpy.

How can I run each script/ghpy on a separate (from GH) thread?

Assume ghpython1 a self-updating component which simply reads from sticky on every calculation then passes the result to the output.

We also have ghpython2 which takes a bunch of inputs and saves them to the sticky that ghpython1 reads.

Now, I would like Grasshopper (all of its single threaded components) to run on one CPU0, ghpython1 to run on CPU1 and ghpython2 to run on CPU2.

Can I do that with any of the System.Threading classes?

(if you think necessary split this thread into a new one only for threading with python)

There’s no simple way of doing that.

Thanks Keyu, I’m not looking for a simple way, only that it works.

I have hundreds of self updating components doing simple things and GH starts lagging.

Can I somehow in SDK mode make the class MyComponent(component) run using threading? Invoking threading from a def before the class?

I saw your reply before you deleted it. Yeah I am learning as I go forward, this is the only way as I use IronPython in my free time while I work with GH. I cannot afford investing Work time into learning IronPython.