Let's take the following Python code:
a = 3
print(a)
As far as I know, a is a reference to an object of class int — correct me if I am wrong. Diagrammatically, it should look something like this, as far as I know.
The object of 'int' class
containing value 3
|---|
a ----> | 3 |
|---|
Does the 'int' object in memory only contain the value 3 or it contains some space for other variables as well?
Our professor told us that it looks something like below:
The object of class 'int'
|--------|
| ___ |
a ----> | |3| |
| --- |
|--------|
So, is the remaining space utilized by some other variables?
sys.getsizeof()to check the size 3 has a size of 28 bytes. So yes, there is other information contained within the int object.