Member-only story
Go For Python Developers
Part 2: Primitive Datatypes
We are continuing with check for Primitive data type in Python and Go. For other article in the series check the reference at the end of the article.

Integer
Integers are non-fractional numbers. They can be either signed or unsigned.
Size
In python, the byte size allocated to the integer is dynamic. Take the following example as a reference:
>>> import sys
>>> sys.getsizeof(0)
24
>>> sys.getsizeof(1)
28
>>> sys.getsizeof(1<<30))
32
>>> sys.getsizeof(1<<60)
36
>>>
In Python, int
can hold integer of any size but it comes at a cost of memory. Python3 uses base 2 power 30. The size starts at 28 for non-zero values and increases by 4 bytes for an increase in base. Implementation is different for python2. Also, I took the values experimentally using python3 so take with a grain of salt.

Go follows the traditional approach. The user is the one deciding the size of the integer.