>>> import sys
>>> sys.getsizeof([])
32
>>> sys.getsizeof([1])
36
>>> sys.getsizeof('')
25
>>> sys.getsizeof('a')
26
>>> sys.getsizeof('cam')
28
I've a vague idea of referential and compact arrays.
In Python, lists are referential arrays,so they use more memory for storing the memory locations of the referred elements.
I could only infer from above examples that an integar in a list occupies an extra 4 bytes(32+4). Strings are array of characters.A unicode character should occupy 2 bits.
Why is an empty string occupying 25 bytes?
why is an empty list occupying 32 bytes?
sys.getsizeof()are bytes not bits. And a Unicode character needs more than 2 bits. :)'a'is not a Unicode string.