float / double support in Python?

Mike C. Fletcher mcfletch at rogers.com
Fri Feb 7 00:09:00 EST 2003


Brandon Van Every wrote:

> What about vectors?  My C++ code has, oh, only a few zillion of those.

So does everyone else's 3D code ;) .  Python objects are heavier than 
the classes you often create in C++ for compact and efficient storage of 
discrete data-records, (for instance, every piece of data associated 
with a vertex (colour, normal, position, multiple texture coordinates, 
meta-data, etceteras)).  However, the Numeric Python extensions provide 
_multi-dimensional_ arrays of various data-types, so you can easily 
represent arrays of vectors efficiently.

What Python is going to be slow on is your classic low-level 3D 
operations (e.g. tessellation, generating sub-division-surface levels, 
representing individual polygons/vertices).  You can often re-formulate 
the operations as array operations, but every once in a while you run 
into an operation that just requires breaking everything down to 
individual objects.

In other words, Python tends to work at the "node" level for 3D 
operations (e.g. processing an entire node's vertex, colour, texcoord 
arrays), but it's not great at discrete lower-level operations.  That's 
where you start to see extensions and utility functions coded in C (or 
C++ if you prefer ;) ) becoming attractive.

BTW, another area where Python trails C/C++ is access to parallelisation 
mechanisms.  AFAIK there's nothing in Numeric Python that takes 
advantage of SIMD, so even on large matrices (where Python is normally 
OK) you could find a significant advantage for C/C++ coded nodes which 
use SIMD instructions.

Why does this thread have such a weird vibe?  I do a heck of a lot of 3D 
programming in Python, and love to talk about it, but I've been avoiding 
the thread 'cause it seems so... confrontational.  Oh well, looks like I 
finally got drawn in anyway.  Peace all,
Mike

Brandon Van Every wrote:

>Carlos Ribeiro wrote:
>  
>
>>On the other hand, NumPy is highly optimized
>>- you pay the object encapsulation price only once for the entire
>>matrix.
>>    
>>
>
>What about vectors?  My C++ code has, oh, only a few zillion of those.
>
>I think what you're telling me is I will suffer memory loss in the interest
>of flexibility.
>
>--
>Cheers,                         www.3DProgrammer.com
>Brandon Van Every               Seattle, WA
>
>20% of the world is real.
>80% is gobbledygook we make up inside our own heads.
>  
>
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/








More information about the Python-list mailing list