Can someone please explain why

n = 50000000
lst = [i for i in range(n)] # or xrange(n) in Python 2

crashes with MemoryError on a 32-bit system, while

n = 50000000
lst = n*[0]
for i in range(n):  # or xrange(n) in Python 2
    lst[i] = i

works?

Thanks,

Gary Litvin
www.skylit.com

_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to