In Python, how big can an array/list get? I need an array of about 12000 elements. Will I still be able to run array/list methods such as sorting, etc?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
It varies for different systems (depends on RAM). The easiest way to find out is
import six six.MAXSIZE 9223372036854775807
This gives the max size oflist
anddict
too ,as per the documentationI'd say you're only limited by the total amount of RAM available. Obviously the larger the array the longer operations on it will take.
Sure it is OK. Actually you can see for yourself easily:
Running the those lines on my machine took:
But sure as everyone else said. The larger the array the slower the operations will be.
In casual code I've created lists with millions of elements. I believe that Python's implementation of lists are only bound by the amount of memory on your system.
In addition, the list methods / functions should continue to work despite the size of the list.
If you care about performance, it might be worthwhile to look into a library such as NumPy.