import numpy
pre_list = [1, 2, 3, 4]
post_array = numpy.array(pre_list)
post_array[2] = 10
print(pre_list)
I notice that [1, 2, 3, 4]
is printed, which means pre_list
was not modified. I guess numpy copied each elements of pre_list
, and it may cost time cn
, where n is len(pre_list), c is a constant. Can I create an array as a view onto a native list, so that they can share elements?
I want to do so, because a list is given, I hope to implement an algorithm on it in a time complexity logn
, but either use method functions of ndarray
for convince.