[Tutor] Why does counting to 20 million stress my computer? (original) (raw)

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jul 20 19:53:04 CEST 2004


for k in range(max):

This line creates a list of max numbers. Each number takes up several bytes of RAM(4+?). So 20 million numbers is over 80MB RAM being used.

You probably should investigate generators for this kind of thing, or at least use xrange() instread of range()

Alan G.



More information about the Tutor mailing list