While playing around with sys.getsizeof()
, I noticed that it returns higher values for ints
as their magnitude grows, signifying that they use more memory:
>>> sys.getsizeof(3)
28
>>>
>>> sys.getsizeof(300000000000000000000000)
36
However with floats
, I get the same memory usage regardless of magnitude:
>>> sys.getsizeof(3.0)
24
>>> sys.getsizeof(300000000000000.111111111)
24
>>> sys.getsizeof(300000000000000000000000.111111111)
24
>>> sys.getsizeof(300000000000000000000000.1111133333333331111)
24
According to the docs, I should be getting back the accurate memory usage of built-in types:
Return the size of an object in bytes. The object can be any type of object. All built-in objects will return correct results, but this does not have to hold true for third-party extensions as it is implementation specific