sys.getsizeof reports an object's shallow memory size in bytes. For lists, it makes hidden growth overhead visible: Python reserves spare pointer slots so many appends avoid immediate reallocation. section 3.5
>>> import sys
>>> mylist = []
>>> for i in range(25):
... l = len(mylist)
... s = sys.getsizeof(mylist)
... print(f'len = {l}, size = {s}')
... mylist.append(i)
Run the loop to compare each list length with sys.getsizeof's reported size as items are appended. section 3.5
Observe capacity steps
The reported size can remain unchanged across several appends, then jump: lengths 1–4 report 96 bytes, length 5 reports 128, and length 9 reports 192. These steps expose reserved capacity rather than a byte-for-byte count of element contents. section 3.5

