check memory size of objects:
import sys
sys.getsizeof(object)
note:
memory represents in bytes
python 2.7.13
>>> import sys
>>> x=2
>>> type(x)
<type 'int'>
>>> sys.getsizeof(x)
12
>>> y=2.3
>>> sys.getsizeof(y)
16
>>> z=3+4j
>>> sys.getsizeof(z)
24
>>> a=True
>>> sys.getsizeof(a)
12
>>> b="siva"
>>> sys.getsizeof(b)
25
>>> c=[1,2,3]
>>> sys.getsizeof(c)
48
>>> c=[10,2.3,"siva"]
>>> sys.getsizeof(c)
48
>>> d=(1,2,3)
>>> sys.getsizeof(d)
40
>>> e={1,2,3}
>>> sys.getsizeof(e)
116
>>> f={'maths':75,'science':80}
>>> sys.getsizeof(f)
140
>>>
python 3.6.2
>>> import sys
>>> x=2
>>> sys.getsizeof(x)
28
>>> y=2.3
>>> sys.getsizeof(y)
24
>>> z=3+4j
>>> sys.getsizeof(z)
32
>>> a=True
>>> sys.getsizeof(a)
28
>>> b="siva"
>>> sys.getsizeof(b)
53
>>> c=[1,2,3]
>>> sys.getsizeof(c)
88
>>> d=(1,2,3)
>>> sys.getsizeof(d)
72
>>> e={1,2,3}
>>> sys.getsizeof(e)
224
>>> f={'maths':75,'science':80}
>>> sys.getsizeof(f)
240
>>>
import sys
sys.getsizeof(object)
note:
memory represents in bytes
python 2.7.13
>>> import sys
>>> x=2
>>> type(x)
<type 'int'>
>>> sys.getsizeof(x)
12
>>> y=2.3
>>> sys.getsizeof(y)
16
>>> z=3+4j
>>> sys.getsizeof(z)
24
>>> a=True
>>> sys.getsizeof(a)
12
>>> b="siva"
>>> sys.getsizeof(b)
25
>>> c=[1,2,3]
>>> sys.getsizeof(c)
48
>>> c=[10,2.3,"siva"]
>>> sys.getsizeof(c)
48
>>> d=(1,2,3)
>>> sys.getsizeof(d)
40
>>> e={1,2,3}
>>> sys.getsizeof(e)
116
>>> f={'maths':75,'science':80}
>>> sys.getsizeof(f)
140
>>>
python 3.6.2
>>> import sys
>>> x=2
>>> sys.getsizeof(x)
28
>>> y=2.3
>>> sys.getsizeof(y)
24
>>> z=3+4j
>>> sys.getsizeof(z)
32
>>> a=True
>>> sys.getsizeof(a)
28
>>> b="siva"
>>> sys.getsizeof(b)
53
>>> c=[1,2,3]
>>> sys.getsizeof(c)
88
>>> d=(1,2,3)
>>> sys.getsizeof(d)
72
>>> e={1,2,3}
>>> sys.getsizeof(e)
224
>>> f={'maths':75,'science':80}
>>> sys.getsizeof(f)
240
>>>
No comments:
Post a Comment