Speed of data structures in python

Mike C. Fletcher mcfletch at rogers.com
Fri Mar 10 12:40:23 EST 2006


Dave wrote:
> Hi. I am learning PyOpenGL and I am working with a largish fixed scene  
> composed of several thousand GLtriangles. I plan to store the coords and  
> normals in a NumPy array.
>
> Is this the fastest solution in python? would i be significantly better  
> off (timewise or otherwise) using some other data structure to hold this  
> information? no other data structure appears as convenient, but am i  
> loosing valuable time?
>
> I am new to 3d programming so please feel free to state the obvious,  
> thanks.
>   
There are two major approaches you can take:

    * array-based geometry -- this relies on fast memory-transfer rates
      operating a C speeds
    * display-list-based geometry -- this relies on moving all of the
      data over to the card

If you can reduce your entire (static) scene to a single display-list 
call, you'll likely find that it's faster than using array-based 
geometry.  If you have special effects (e.g. transparency), then you'll 
likely find that coding as array-based geometry is the more practical 
approach.

By way of reference, OpenGLContext uses array-based geometry throughout 
these days.  I had (at one point) code to make individual display-lists 
out of particular indexed face sets, but it didn't provide any 
performance boost when applied at the single-object level (i.e. 
thousands of display lists with all the traversal code still required), 
so the code is now disabled.  Simpler (static) scenegraphs where there's 
lots of traversal between nodes should be a much bigger win for 
converting the whole thing to a single display list.

HTH,
Mike

-- 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list