Answers for "how to get the size of an object in python"

1

how to get the size of an object in python

import sys
object = set()

print(sys.getsizeof(object))
##### will get 216 possibly based on version 3.9 ###

###  use different objects like list(), dict(), str(), int(), float(), etc..###
### for getting to know size of each objects and use the most appropriate ###
## particularly set and dict will seem to not change in size even after ##
## adding lots of values but they are just so huge, only use them to store ##
## large values ##
Posted by: Guest on April-07-2021

Code answers related to "how to get the size of an object in python"

Python Answers by Framework

Browse Popular Code Answers by Language