-
Kirill Smelkov authored
In NumPy, ndarray has .resize() but actually it does a whole array copy into newly allocated larger segment which makes e.g. appending O(n). For BigArray, we don't have that internal constraint NumPy has - to keep the array itself contiguously _stored_ (compare to contiguously _presented_ in memory). So we can have O(1) resize for big arrays. NOTE having O(1) resize, here is how O(δ) append can be done: A # ZBigArray e.g. of shape (N, 3) n = len(A) # lengh of A's major index =N A.resize((n+δ, A.shape[1:])) # add δ new entries ; now len(A) =N+δ A[-δ:] = <new-data> # set data for last new δ entries /cc @klaus
ca064f75