float / double support in Python?

John Machin sjmachin at lexicon.net
Fri Feb 7 00:42:56 EST 2003


"Brandon Van Every" <vanevery at 3DProgrammer.com> wrote in message news:<ltC0a.2919$tO2.327679 at newsread1.prod.itd.earthlink.net>...
> Terry Reedy wrote:
> >
> > Python proper only uses 'floats' which (for CPython) are 8 byte C
> > doubles.
> 
> Um, that's like, absolutely brain-dead to a 3D game developer. 

Perhaps you might take a few moments to explain what the problem is.
Is it because of the extra memory? BTW, Python objects have overhead
(a reference count and a type-pointer). For example, on the Intel
32-bit architecture, you need 8 bytes for the C double, 4 bytes for
the reference count and 4 bytes for the type pointer. How many
floating point values do you have in your data structures in a typical
3D game? What is the market memory constraint -- 128Mb home PC?

You may find it worthwhile to set up a C extension that manages your
data structures in a memory-efficient fashion and does the major
number-crunching, leaving Python for the high-level stuff. Python is
often used to prototype and verify crunchy stuff, which if far too
crunchy can then be written in C.




More information about the Python-list mailing list