3

I'm just curious, why these lists are not of the same size?

from sys import getsizeof

a = list(1 for i in range(10))
print(getsizeof(a))  # prints 84

b = [1 for j in range(10)]
print(getsizeof(b))  # prints 100

c = [1] * 10
print(getsizeof(c))  # prints 76
Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
Arctic45
  • 1,078
  • 1
  • 7
  • 17

0 Answers0