ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Add reserve method for owned arrays

Open ssande7 opened this issue 2 years ago • 0 comments

This PR adds an array.reserve(axis, additional) method for use when appending multiple times to an array. It abstracts over the code in append that was calling OwnedRepr::reserve in order to expose it.

Benchmark results (appending 100 times to an empty array):

test push_no_reserve ... bench:         900 ns/iter (+/- 52)                                                                                                                          
test push_reserve    ... bench:         739 ns/iter (+/- 50) 

Note I'm new to the crate so I may have missed something, but happy to iterate if there's more to do.

ssande7 avatar Mar 11 '23 02:03 ssande7