maximum length of a list & tuple

Josiah Carlson jcarlson at uci.edu
Sat Apr 10 15:35:43 EDT 2004


> I just would like to know if there is any limit to a list or tuple.

It depends on how much memory you have.

Run the following and the last thing it prints out is your limit...

     c = 1
     while c < 2**32:
         try:
             d = [1]*c
             print c
             c *= 2
         except:
             break


  - Josiah



More information about the Python-list mailing list