List limits

Nick Coghlan ncoghlan at iinet.net.au
Tue Dec 21 05:33:17 EST 2004


Raymond Hettinger wrote:
>>How many items can be stored in a Python list? I have close to 70,000
>>items... is this within a lists limits?
> 
> 
> Lists store pointers to objects.  Unless you have a lot of duplicates, it is the
> objects themselves that will consume most of your memory.  The list itself will
> likely be small in comparison.

Given the size of the counter, is it actually physically possible for a list to 
run out of room before the application runs out memory?

Even list(None for x in xrange(sys.maxint)) wouldn't do the trick, since each of 
those pointers to None is taking 4 bytes of memory, and Python's internal 
structures are already chewing up some of the address space.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list