2 ms·
but it is idiomatic in C, which is the point of the slide. C was built around a performance focused idiom, which is to pre-allocate memory and then do in place
by metaphorm 14y ago
but it is idiomatic in C, which is the point of the slide. C was built around a performance focused idiom, which is to pre-allocate memory and then do in place writes and swaps to mutate the buffer to the state you need it to be. Python is built around an idiom of largely creating copies of objects and appending them to dynamically allocated lists. Its a much slower idiom.
- mixmastamyk 14y agoYes, the question was regarding this line in the original post: "I personally find it really frustrating not being able to easily pre-alloc lists in Python." So my mind of course wandered in the direction of how to do that.