如何定位操作ndarray[slice object] = array的源代码?

How to locate source code of the operation ndarray[sliceobject] = ndarray?

我需要知道以下Python操作的时间复杂度 ndarray[sliceobject] = ndarray.

为此,我想查看源代码,但我不知道在 numpy 中的何处查看。我正在使用 this repository 但我找不到任何关于代码结构的文档,这让我的研究很费时。

我已经检查了 Guide to Numpy 参考资料,但没有发现任何关于此问题的信息。

我需要此操作小于 O(n),并希望确保是这样。

我终于做了一些计时测试,最后得到了以下情节: 毫无疑问 ndarray[sliceobject]=ndarray 是 O(n),n 是第二个 ndarray.

的大小

我的测试基本上包括构造一个二维 ndarray A,固定大小,其中包含集合 B,一个 ndarray,大小可变。测试代码在这里:

import time
import numpy as np
import matplotlib.pyplot as plt

start = time.time()

step = 70000 
iterations = 10000 

nb_elements = step*iterations 
matrix_width = step
matrix_height = iterations
A = np.arange(nb_elements).reshape(matrix_height,matrix_width)

plt.xlabel('n')
plt.ylabel('Temps(secondes)')
xValues = []
yValues = []

for n in range(0,iterations):
    B = np.arange(nb_elements*(n+1),nb_elements*(n+1)+(step*  (n+1))).reshape((n+1),step)
    idx = slice(0,(n+1),1)
    start = time.time()
    A[idx] = B
    end = time.time()
    print("step : "+str(n))
    xValues.append(B.size)
    yValues.append(end-start)

plt.plot(xValues,yValues,'b.-')
plt.show()