Dave Cheney 3/1/2020

Are large slices more expensive than smaller ones?

Read Original

This article clarifies a common misconception in Go programming: assigning a large slice is not more expensive than assigning a small one. It explains that all slices in Go are the same size (three machine words), containing a pointer, length, and capacity. Therefore, copying a slice variable only copies these three words, regardless of the underlying array's size.

Are large slices more expensive than smaller ones?

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week