With the full qualification that there isn’t really a good way to benchmark the 
two against each other within Nuke, I think it’s pretty safe to assume that TCL 
will be faster in the majority of cases. Since Python expressions are called 
through TCL, at the very least, they will suffer a consistent (if likely 
miniscule) overhead no matter what. Additionally, the double-edged sword of 
Python is that, while it’s typically easier for beginners to pick up, it also 
makes it much easier to write inefficient code than TCL does, so unless you’re 
a strong/smart Python programmer, you will likely introduce more avoidable 
overhead manually.

The general rule I tend to try and adhere to (and would recommend) is, if 
something can be done in TCL without exceeding a certain (admittedly 
subjective) threshold of complexity, I’ll use that over Python.

The function you’ve listed can basically be written like so as a TCL expression:

[lindex [split [lindex [split [file tail [value parent.input0.file]] _] 0] .] 0]


-Nathan



From: Luca Fiorentini 
Sent: Friday, September 21, 2012 5:21 AM
To: Nuke Python discussion 
Subject: [Nuke-python] python and tcl

Hi!

Is tcl  faster than python inside nuke when you have to set knobs on a lot of 
different nodes?
I had this impression and I was trying to convert all the simple expressions 
inside my gizmos but I would like to be sure.
Also, is it possible to translate something like this

def saText():
    try:
        file = nuke.thisGroup().input(0).knob('file').value()
        text = os.path.split(file)[1]
        text = text.split('_')[0]
        text = text.split('.')[0]
        return text
    
    except:
        return 'Bad naming convention/location'

to tcl or I have to use python?

Thanks in advance!
-- 
Luca Fiorentini - 3D Lighting Artist
My Showreel - My blog - My Flickr




--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to