def original_app(A, B, C, D):
    final = np.zeros((6 * N, 6 * N), dtype=A.dtype)
for i in range(N):
    for j in range(N):
        for k in range(3):
            for l in range(3):
                final[6 * i + k][6 * j + l] = A[3 * i + k][3 * j + l]
final[6 * i + k + 3][6 * j + l + 3] = B[3 * i + k][3 * j + l]
final[6 * i + k + 3][6 * j + l] = C[3 * i + k][3 * j + l]
final[6 * i + k][6 * j + l + 3] = D[3 * i + k][3 * j + l]
return final

def slicing_app(A, B, C, D):
    out = np.zeros((N, 2, 3, N, 2, 3), dtype=A.dtype)
out[:, (0), :, :, (0), :] = A.reshape(N, 3, N, 3)
out[:, (0), :, :, (1), :] = D.reshape(N, 3, N, 3)
out[:, (1), :, :, (0), :] = C.reshape(N, 3, N, 3)
out[:, (1), :, :, (1), :] = B.reshape(N, 3, N, 3)
return out.reshape(6 * N, 6 * N)
Оптимизация назначения в массив из разных массивов — NumPy