Take the 2-minute tour ×  Why this code snippet is giving
different size in bytes with two different functions. I am using
32 bit version of python 2.7.3  1) with dictionaries:-  from sys
import getsizeof l = range(20)             d = {k:v for k,v in
enumerate(l)}    #creating a dict d.__sizeof__()   #gives size
in bytes  508              #size of dictionary 'd' in bytes  524
#size of same dictionary 'd' in bytes (which is different then
above)  2) with list:-  from sys import getsizeof l = range(20)
100           #size of list 'l' in bytes  116           #size of
same list 'l' in bytes  3) with tuple:-  from sys import
getsizeof t = tuple(range(20)) 92             #size of tuple 't'
in bytes  108            #size of same tuple 't' in bytes  Would
anyone tell me why this kind of behaviour, when documentation of
both function says that they return size of object in bytes.
share|improve this question add comment  1 Answer  From the sys
docs:  getsizeof() calls the object’s sizeof method and adds a