0

For my programming project, I need to create a list of 65536 (2^16) lists which are again 65536 elements long. Each of the internal lists contain integers with two digits in hexadecimal. I was wondering if my machine could handle this very long nested list without any loss of value, let alone the running time.

I read a response on here, which says that sys.maxsize gives the maximum size of a list, and my machine gives me 2147483647. However, does it follow from the fact that the maximum elements that can be stored in a list is 2147483647, it can store 65536 lists, although each of those lists are again 65536 elements long?

Namudon'tdie
  • 306
  • 1
  • 10

2 Answers2

1

The limit on the length of a list only refers to the number of elements in a list. It doesn't matter what those elements are, since the list itself only includes references to them, it doesn't actually store the content of the objects inside itself.

In your case, you have a list which stores 65536 elements, and 65536 is less than the maximum size of a list, so that's fine. The fact that the elements of the list are themselves lists is irrelevant.

David Z
  • 128,184
  • 27
  • 255
  • 279
0

The maximum size of a python list on a 32 bit system is 536,870,912 elements.

I don't believe that is limited to the total elements in each list. (65536^2 = 4,294,967,295 which exceeds this.)

Why not try it and find out?

Jonah Mann
  • 23
  • 5