Okay so amateur question here:
>>> sys.getsizeof(int())
24
>>>sys.getsizeof(1) #1 is stored as 32 bit int so we add 4 bytes making total of 28
28
>>>sys.getsizeof(1073741824 - 1) #(2^30)-1
28
>>>sys.getsizeof(-1073741824 + 1) #-(2^30)+1
28
>>>sys.getsizeof(1073741824) #(2^30)
32
So as I understand it, an empty int reference in Python is stored in 24 bytes. Once I use this int reference to create an object it adds extra bytes depending on the number.
As we can see in the code up, once I added a number the size increased by 4 bytes (32 bits) which is logical since int is 32 bits (and can grow 64, 96, ...).
However, I expected that the extra 32 bits were divided as 31 bits for the number and 1 bit for the sign, but it turns out that only 30 bits were used for the number and 1 bit for the sign (2^30 was stored in 64 bits). So what is the last bit used for?
It gets even more confusing:
>>> sys.getsizeof(1152921504606846976 - 1) #(2^60)-1
32
>>> sys.getsizeof(1152921504606846976) #(2^60)
36
64 bits can store up to (2^60)-1 & not (2^63)-1, so here 60 bits for the number & 1 bit for the sign, what are the 3 bits left used for?