float / double support in Python?
Brandon Van Every
vanevery at 3DProgrammer.com
Fri Feb 7 05:11:14 CET 2003
Isaac To wrote:
>>>>>> "Brandon" == Brandon Van Every <vanevery at 3DProgrammer.com>
>> Um, that's like, absolutely brain-dead to a 3D game
>> developer. Does Numeric Python give you a 4-byte float
> The only benefit of 4-byte floats on real computers is that it
> consumes less space.
"Only" benefit??!? Spoken like a guy who doesn't push millions of triangles
around! Or use 3D APIs that only understand 4-byte floats.
> Computations done in 4-byte floats are seldom
> faster than those in 8-byte doubles (some computers convert them back
> and forth to 8-byte doubles even for 4-byte floats, so they can even
> be slower).
All CPUs I've written ASM code for are slower at division and square root
when the precision is higher.
> But the benefit of space efficiency is doubtful in
> Python, since every object uses 8 more bytes:
Ok, so Python is a numerical pig. Good to know. C++ just got a lot more
case uses. Python only for when performance does not matter.
> On the other hand, if you have a whole bunch of double's to store,
> look at the array module. It allows you to store a bit array of
> values, without making each of them an object. And in that array
> module, you can choose to store 4-byte or 8-byte values. When you
> actually get values from them, it will wrap up the values to an
> object, so it is slower, but more space efficient.
If the point of switching to Python is to gain ease-of-use, such antics are
Brandon Van Every Seattle, WA
20% of the world is real.
80% is gobbledygook we make up inside our own heads.
More information about the Python-list