• Kirill Smelkov's avatar
    bigarray: In-place .append() · 1245acc9
    Kirill Smelkov authored
    ca064f75 (bigarray: Support resizing in-place) added O(1) in-place
    BigArray.resize() which makes possible for users to append data to BigArray in
    O(δ) time.
    But it is easy for people to make off-by-one mistakes when calculating
    indices for append.
    So provide a convenient BigArray.append() which simplifies the following
        A                               # ZBigArray e.g. of shape       (N, 3)
        values                          # ndarray to append of shape    (δ, 3)
        n, δ = len(A), len(values)      # length of A's major index  =N
        A.resize((n+δ, A.shape[1:]))    # add δ new entries ; now len(A) =N+δ
        A[-δ:] = values                 # set data for last new δ entries
    /cc @klaus
__init__.py 15.4 KB