I'm trying to understand the below snippet.
import sys
variable = 30
print(sys.getsizeof(variable)) #prints 28
If I change integer value with string
import sys
variable = "30"
print(sys.getsizeof(variable)) #prints 51
So does it means integer object makes use of less memory than string object.
Please let me know how Python makes use of memory.
Yes integer object use 28 byte of memory while string object is getting bigger size of memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With