How to get object size in Python

Опубликовано: 09 Октябрь 2024
на канале: 60 Second How-to
100
2

Subscribe for more
#howto #python #pythonprogramming #pythontutorial #object #memory #variable #tutorial #1minutevideo #60secondsvideo #fasttutorial #beginners #coding #developer

Full Code Snippet

Example 1:
--------------------------
import sys
a = 10
print(sys.getsizeof(a))

Example 2:
--------------------------
import sys
a = 10.5
print(sys.getsizeof(a))

Example 3:
--------------------------
import sys
a = 'abc'
print(sys.getsizeof(a))

Example 4:
--------------------------
import sys
a = ['a', 'b', 'c']
print(sys.getsizeof(a))

Example 5:
--------------------------
import sys
a = {'a':1, 'b':2, 'c':3}
print(sys.getsizeof(a))