float / double support in Python?

Tim Peters tim.one at comcast.net
Thu Feb 6 18:00:05 EST 2003


[Brandon Van Every]
> float and double support is very critical to ease-of-use for my
> 3D graphics programming work.

A Python float is a wrapper around a platform C double.  Python has no type
corresponding to the platform C float.

> How does Python fare for number crunching?  I'm not so much concerned with
> efficiency, I'm not expecting much, but rather syntax, universality of
> support on different platforms, or other headaches / gotchas.

You'll want to install the popular Numpy extension.  That adds whole-array
syntax to the language, and a large number of array-oriented functions and
methods.  They run at native C speed.

> For instance it's not acceptable to represent a float /double as a
> string, it has to be 4 bytes / 8 bytes.

A Python float is a native C double, but each float is-- like everything
else in Python --"an object", and so also has a Python object wrapper around
it.

> I heard at one point that people were considering abolishing floating
point
> support from the language?

Sure, and you'd have a hard time coming up with an idea that "people"
weren't considering at some time.  Guido never considered abolishing fp,
though.  He has briefly considered abolishing builtin support for complex
numbers, but only when I whine about them <0.1j wink>.






More information about the Python-list mailing list