Elisp: List vs Vector
Differences Between List and Vector
Here's the differences between List and Vector:
- List, access time to nth element is proportional to size of n.
- List length can change by adding or removing the first element. These operations have constant time.
- Vector, access time to any element is constant.
- Vector's length cannot change. (if you create a new copy of a vector, the time required is proportional to the vector's length)
In short, list can grow or shorten, but if you have a long list, say 1 thousand items, getting the value of 900th item is slow.
Vector has fixed length. Getting the value of any element is fast.