How can we reserve memory (or allocate memory without initialization) in Julia? In C++, a common pattern is to call reserve
before calling push_back
several times to avoid having to call on malloc
more than once. Is there an equivalent in Julia?
I think you are looking for sizehint!
help?> sizehint!
search: sizehint!
sizehint!(s, n)
Suggest that collection s reserve capacity for at least n elements. This can
improve performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With