Int type is int32 or int64 in default in Python3.
How can we specify int8/int16 when declaring variable?
It is not possible in Python?
It is waste of memory if the int object is small and int8/int16 cannot be specified.
Python doesn't have any built-in support for 8 or 16-bit integers. NumPy, on the other hand, does support the sizes you're looking for:
import numpy as np
print(np.uint8(22))
Afaik python chooses the type according to the size of the number and there is no way of specifying which type of int you want python to use. If you are concerned about the waste of memory, python may not be the correct choice in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With