Rationale for core Python numeric types
Tim Peters
tim.peters at gmail.com
Thu Jun 17 11:39:36 EDT 2004
[Matt Feinstein]
> 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?
Since it hasn't been mentioned yet: see Python's standard "struct"
module. That's the intended way to do I/O conversions from/to binary
files, and deals gracefully with the usual range of integer and float
sizes, signed versus unsigned distinctions, endian issues, and
platform-specific sizes & alignment versus "standard" sizes and
alignment. Note that just having a pile of distinct numeric types
would leave half those issues untouched.
More information about the Python-list
mailing list