maximum length of a list & tuple
Tim Roberts
timr at probo.com
Sun Apr 11 00:19:36 EDT 2004
Josiah Carlson <jcarlson at uci.edu> wrote:
>> 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
Interesting experiment. I get 64M on my 384MB machine, which suggests 4
bytes per list entry. Of course, now my swap file is packed full, and all
my apps are running slowly while they page themselves back in...
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list