[Edu-sig] MemoryError?

Litvin litvin at skylit.com
Sat Apr 21 22:50:57 CEST 2012

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



Gary Litvin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20120421/b1fed961/attachment.html>

More information about the Edu-sig mailing list