I don't have hard evidence to support it, but on paper the knobChanged
callback almost has to be more efficient. And even if it isn't (which I
don't suspect), it's a hell of a lot cleaner and easier to implement and
modify if necessary.
When using a pre-registered callback (which you should), the code will be
byte-compiled once and reused. You can set as many fields of a knob as you
want in one shot (even using .fromScript if you want).
Using an expression means the plugin calls the API method to evaluate the
expression, which then immediately uses a nested TCL eval (square brackets)
to call a `python` TCL proc. This in turn has to `eval` the Python
expression string every time, and then the result of that eval bubbles back
up to the plugin API. This happens every time the viewer redraws (regardless
of whether a knob changes), times the number of individual expressions.
-Nathan
-----Original Message-----
From: John RA Benson
Sent: Tuesday, August 12, 2014 2:42 PM
To: Nuke Python discussion
Subject: [Nuke-python] Expression vs callback efficiency?
Hey there -
Sort of a general question for a specific problem:
I have a 3x3 color matrix I am needing to pass values to. Does anyone have
any idea what would be more efficient: a single expression returning a list
of lists, duplicated for each value in the matrix but sliced appropriately
per value ( exp()[0][0], exp()[0][1], etc), or a callback that did a
fromScript(myFormattedForMatrixList) and basically pushed the values at
every relevant knob change?
Or is there something better I'm not thinking of, other than writing a
plugin?
The multiple expressions don't seem as efficient, in that it is being
evaluated 9 times, but I'm not sure how efficient a knobChanged callback
ultimately ends up being in conjunction with all the other callbacks when
the script gets large.
Thanks -
Jrab_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python