Rationale for core Python numeric types

Dave Brueck dave at pythonapocrypha.com
Thu Jun 17 17:30:31 CEST 2004

Matt wrote:
> I'm new to Python, and was somewhat taken aback to discover that the
> core language lacks some basic numerical types (e.g., single-precision
> float, short integers). I realize that there are extensions that add
> these types-- But what's the rationale for leaving them out? Have I
> wandered into a zone in the space/time continuum where people never
> have to read binary data files?

The struct module is the most common way of reading/writing binary files.
For complex structures stored in files I sometimes use ctypes.

As for the rationale nehind not having types like 'short', 'long', etc. I
can only guess - perhaps the reasons include (1) their presence in a
language encourages programmers to worry about details they usually don't
need to be burdened with and (2) for many (most?) cases, you're really
talking about marshalling data - an OS API takes a short int, a file header
has an unsigned long, a network message requires a byte for bit fields,
etc. - and the problem of data marshalling doesn't necessarily need to be
tied that closely to the numeric types of the language. Again, these are
just my guesses...


More information about the Python-list mailing list