11
I have a very large list Suppose I do that (yeah, I know the code is very unpythonic, but for the example's sake..):
n = (2**32)**2
for i in xrange(10**7)
li[i] = n
works fine. however:
for i in xrange(10**7)
li[i] = i**2
consumes a significantly larger amount of memory. I don't understand why that is - storing the big number takes more bits, and in Java, the the second option is indeed more memory-efficient...
Does anyone have an explanation for this?