Guido van Rossum
๐ค SpeakerAppearances Over Time
Podcast Appearances
An object is basically a pointer to a bunch of memory that contains more pointers.
Well, not quite, but there are a lot of them.
So to simplify a bit, we look up in one of the objects, what is the type of that object?
And does that object type define an add operation?
And so you can imagine that there is a sort of a type integer that knows how to add itself to another integer.
And there is a type floating point number that knows how to add itself to another floating point number.
And the integers and floating point numbers are sort of important, I think, mostly historically, because in the first computers, you used the sort of the same bit pattern when interpreted as a floating point number had a very different value than when interpreted as an integer.
The operator is more like...
It's an index in a list of functions that the integer type defines.
And so the integer type is really a collection of functions, and there is an add function, and there's a multiply function, and there are like 30 other functions for other operations.
There's a power function, for example.
And you can imagine that
In memory, there is a distinct slot for the add operations.
Let's say the add operation is the first operation of a type and the multiply is the second operation of a type.
So now we take the integer type and we take the floating point type.
In both cases, the add operation is the first slot and multiply is the second slot.
But...
Each slot contains a function, and the functions are different, because the addToIntegers function interprets the bit patterns as integers.
The addToFloat function interprets the same bit pattern as a floating point number.
And then there is the string.