0

As far as I understand, in Python, the List type stores only the pointers to the objects. and when I have, for instance, two lists:

>> a = [1,2,3,4,5,6,7]
>> b = ["1","2","3","4","5","6","7"]
>> sys.getsizeof(a) == sys.getsizeof(b)
>> True

the sys.getsizeof() returns the same size.

So,basically, the size of the list (in terms of memory required) does not depend on the types stored. Is there a way (by calling a single method/function) to find out how much memory a given list and the stored elements (even when the elements are big and complex objects) in it will require?

teoML
  • 784
  • 4
  • 13

1 Answers1

0

Correct. List's are just a collection of pointers to the actual memory at each address. See https://stackoverflow.com/a/30316760/6014330 for a deep explanation on the way python manages memory for built in types

testfile
  • 2,145
  • 1
  • 12
  • 31