Search code examples
pythonperformancecollections

Huge collections in Python


Basically I am storing millions of vector3 values in a list. But right now the vector3s are defined like so:

[5,6,7]

which I believe is a list. The values will not be modified nor I need any vector3 functionality.

Is this the most performant way to do this?


Solution

  • If you are storing millions of them, the best way (both for speed and memory use) is to use numpy.

    If you want to avoid numpy and use only built-in python modules, using tuples instead of lists will save you some overhead.