2

I am working through Practical Common Lisp and a couple of lecture series on YouTube.

I am wondering how resizable vectors work under the hood. And when it is better to use a resizable vector vs an extra large fixed size vector. The fixed size vector, I imagine, will have considerable overhead of resizing when needed. Though will a fixed size vector be significantly faster than a resizable vector?

I am using SBCL on MAC.

I have looked through documentation and forums and have found nothing which is suited to my skill and knowledge level (Novice).

An answer or a pointer to some accessible documentation will be greatly appreciated. I do anticipate that I will have to dive into learning about compilers (and perhaps even regular languages).

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
saq7
  • 1,528
  • 1
  • 12
  • 25

1 Answers1

4

Resizable arrays involve at most one extra indirection and thus are relatively cheap. The flexibility they offer is far more important than the possible inefficiency, so one should use them whenever the array size will have to change - and reconsider only when there is evidence that the inefficiency is caused by resizing.

See

  1. Is premature optimization really the root of all evil?
  2. When is optimisation premature?
Community
  • 1
  • 1
sds
  • 58,617
  • 29
  • 161
  • 278