# Rationale for core Python numeric types

Peter Hickman peter at semantico.com
Fri Jul 16 18:15:11 CEST 2004

```Grant Edwards wrote:
> I disagree.
>
> Things like "eight-bit signed 2's compliment binary number"
> have completely rigorous definitions that are not dependent on
> some particular hardware platform.

What you say is true but the OP does not talk about "eight-bit signed 2's
compliment binary number", he talks about "e.g., single-precision
float, short integers". It is these types that the OP was talking about and

> No, I think you're missing the point. We're talking about
> writing a Python program who's purpose is to manipulate
> externally defined data in externally defined ways.  The data
> are binary numbers of specific lengths (typically 8, 16, and 32
> bits) and the operations are things like 1's compliment, 2's
> compliment, 2's compliment addition and subtraction, left and
> right shift, binary and and or, etc.

Again returning to the OP, I find no mention of "things like 1's compliment, 2's
compliment, 2's compliment addition and subtraction, left and right shift,
binary and and or, etc". Am I missing a post or are you in private conversation
with the OP?

Besides I have not read from the OP what the program is to manipulate external
data in any special fashion. All my programs read external data, manipulate it
and write it out in external formats. I use my PowerPC to run programs that read
and write data from Intel boxes in a format that works for the Intel boxes. I

> You seem obsessed with hardware. :)

The type system, or at least the whole zoo of integers, came about from the
hardware. First there was char and int, because there was only 8 bits anyway and
they were words. Then came 16 bits and the int went up to 16 bits but was now no
longer a synonym for char so we got short int and the cpus started to implement
signing of integers so now we require signed and unsigned integers. The whole
type system came into existence solely to allow access to the feature that cpus
provided.

Python (and Perl, Ruby, Java, etc., etc.) run within VMs of sorts and as such
the language only needs to know about the types that the VM provides not the
types that the cpu provides.

> However, don't try to tell me that I don't
> _need_ to use fixed-length binary 2's compliment numbers.

I have said nothing of the sort, perhaps you should read my post again.

> Don't care about hardware -- at least not the hardware on which
> I'm running Python.

Fine, but back the the OP. "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)."

That is what I was answering, the why Python lacks the numerical types such as
single-precision float and short integers that are found in other earlier
languages and I felt that a little history as to why the type system came about
would go some way to aiding understanding.

```