如何在Julia中保留内存(或在没有初始化的情况下分配内存)?在C ++中,一种常见的模式是在多次调用reserve
之前调用push_back
,以避免不止一次调用malloc
。朱莉娅有同等的东西吗?
答案 0 :(得分:5)
我认为您正在寻找sizehint!
help?> sizehint!
search: sizehint!
sizehint!(s, n)
Suggest that collection s reserve capacity for at least n elements. This can
improve performance.