I am confused :
(1) when int convert to bytearray (or str convert to bytearray) ,why its memory space increase ?
a=1 # int
print 'space of int ',sys.getsizeof(a)
b=bytearray(a) # convert
print 'space of b ',sys.getsizeof(b)
s='h' # str
print 'space of s',sys.getsizeof(s)
b2=bytearray(s)
print 'space of b2',sys.getsizeof(b2)
output:
space of a 12
space of b 26
space of s 22
space of b2 26
(2) I have read this , In-memory size of a Python structure and I have known different types of a python object has different memory size.But I can't figure out its principle.