Alternatives to keeping large lists in memory (python)

后端 未结 9 1384
再見小時候
再見小時候 2020-12-08 16:50

If I have a list(or array, dictionary....) in python that could exceed the available memory address space, (32 bit python) what are the options and there relative speeds? (o

9条回答
  •  醉话见心
    2020-12-08 17:45

    There are probably dozens of ways to store your list data in a file instead of in memory. How you choose to do it will depend entirely on what sort of operations you need to perform on the data. Do you need random access to the Nth element? Do you need to iterate over all elements? Will you be searching for elements that match certain criteria? What form do the list elements take? Will you only be inserting at the end of the list, or also in the middle? Is there metadata you can keep in memory with the bulk of the items on disk? And so on and so on.

    One possibility is to structure your data relationally, and store it in a SQLite database.

提交回复
热议问题