no, the whole script is NOT executed again. Your class is instantiated only once at the beginning, and then RunScript() is run once for every time it is needed (may be thousand of times per solution).
If you want to set some logic at component creation or deletion, you can override Python’s initialization/deletion methods:
def __enter__(self): #alternative
Also, you may override:
but that one relies on the Garbage Collector, and may happen in a very remote time from apparent deletion of the component (use with extreme caution: throwing exceptions in a Garbage Collector call will immediately close the program, and bugs are hard to debug).
Do not rely on what happens in the external scope when using the SKD-mode (object-oriented mode). It’s an implementation detail.
See an example here.init-exit-sample.gh
for Robert McNeel & Associates
EDIT: in 6.7 and onward, the external scope will only evaluate once to make the behavior more apparent. See RH-47124.