5 ms·
Whenever you need random access you use something else. If all you need is sequential access, there are lots of optimizations that can be done to the representa
by bjoli 6y ago
Whenever you need random access you use something else. If all you need is sequential access, there are lots of optimizations that can be done to the representation of lists that make them more efficient.
In guile scheme you gain very little by using vectors instead of lists unless you want random access. There is however a never-ending flood of people coming from python using lists in exciting ways to create accidentally O(n^3) programs :) Those can almost always be re-written to be o(n) using linked lists, otherwise you point them to vectors instead.
- zerr 6y agoBesides random access, I mean the data locality, cache-friendliness in general.
- bjoli 6y agoThat is usually done as a part of the GC. With a generational ormcopying GC you can "defragment" memory so you have the list in a contiguous region. Not as good as a vector of course, but still decent.