On 12/03/2013 at 18:13, xxxxxxxx wrote:
My 2c:
K.I.S.S. and only optimize what really need optimizing.
if not obj:
is slightly faster than
if obj == None:
But even faster is not to do any check at all:
try: except:
And remove the thing that will build up
any except/errors, in this case a faulty
In/Ex List, that will be read for every cycle
giving an error for every cycle (See print below).
I.o.w, refresh the In/Ex List and do a break.
So for example:
for o in xrange(liscount) :
listobj = inexlist.ObjectFromIndex(doc,o)
try:
#do things with your listobj
listobj.Message(c4d.MSG_UPDATE)
except:
inexlist.DeleteObject(o)
myplugin[c4d.MY_LIST] = inexlist # rebuild a correct list
myplugin.Message(c4d.MSG_UPDATE)
print 'GONE' # The error is now only printed once
break # start a new cycle only if errors
Cheers
Lennart