I am looking for the Python equivalent of the C++ vector::reserve(). I don't know how big the list is going to be ahead of time, but I know it's going to be fairly large, and I want to avoid as many resizings as possible as the list is being grown inside a deep inner loop.
The only solution I've come up with so far is very cumbersome compared to the vector::reserve() idiom. That solution is to pre-create the list using [None]*K, tracking the size of the list in a separate counter, appending or setting items into the list as need be, then copying a slice of the list once it's fully constructed. Is there any alternative?