Forum: Poser - OFFICIAL


Subject: New Reality (lux render) Plugin over at Daz...time for Poser Plugin Update?

Ridley5 opened this issue on Jul 26, 2010 · 1724 posts


bagginsbill posted Wed, 04 August 2010 at 11:45 AM

You guys keep reminding me not to optimize, as if that's how I'm spending all my time. I'm not.

Nevertheless, there is no reason to avoid simple one-line differences that affect performance, especially when the slower idiom is more typing as well.

Consider this from odf's ODFLuxportActor.py:

        if normals is not
None and len(self.indices) > 0:<br></br>
           
print >>file, ' "normal N" [n'<br></br>
           
for i in self.indices:<br></br>
               
norm = normals[i]<br></br>
               
print >>file, norm.X(), norm.Y(), norm.Z()<br></br>
           
print >>file, ']n'<br></br>

This version is exactly the same behavior, but will run faster, and is less typing:


        if normals and self.indices:

            print >>file, ' "normal N" [n'

            for norm in normals:

                print >>file, norm.X(), norm.Y(), norm.Z()

            print >>file, ']n'



Take advantage of the fact that None is false, and empty lists are also false. Checking "if x is not None and len(x) > 0" is doing exactly the work that is already built in when you say "if x". The difference is that "if x" is entirely C code, whereas "if x is not None and len(x) > 0" is interpreted Python code.

Don't do looping subscripting on lists unless you have to - use iterators.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)