sys.getsizeof(list(range(10))) # 200
sys.getsizeof([0,1,2,3,4,5,6,7,8,9]) # 144
sys.getsizeof([i for i in range(10)]) # 192
I have very little C experience so this may be over my head, but I am curious as I am playing around with sys.getsizeof
.
I tried to look at the documentation but I only found this:
getsizeof() calls the object’s sizeof method and adds an additional garbage collector overhead if the object is managed by the garbage collector.
Due to my very little C
experience I am not too familiar with GC as well but from my Python-related GC readings, I understand that only references are counted in Python. In the above situation, we aren't saving it to a variable so I am assuming no GC references?