i have big 2d array following shape: b = [b_0, b_1, b_2, b_n] where b_0, b_1, ..., b_n have same number of rows, different number of columns , n may large. have 1d array idx shape (n+1,) , , b_i = b[:, idx[i]:idx[i+1]] and idx[-1] (the last elements of idx ) total number of columns of b . i want same matrix operation every b_i , example: b_i.t()@b_i or 2d array: d = [[d_0], [d_1], ..., [d_n]] with d_0, d_1, ..., d_n have same number of columns equal number of rows of b , different number of rows, , d_i = d[idx[i]:idx[i+1], :] and want compute d_i@b_i . so question how implement in python , avoid using for loop? the following example: import numpy np timeit import default_timer timer # prepare test data n = 1000000 # number of small matrix idx = np.zeros(n+1, dtype=np.int) idx[1:] = np.random.randint(1, 10, size=n) idx = np.cumsum(idx) b = np.random.rand(3, idx[-1]) # computation start = timer() c = [] in range(n): b_i = b[:, idx[i]:idx[i+1]