Is there an easier and more efficient way to make memory in single mode.
import numpy as np
ar = np.array(a[l:r])
ar += c
a = a[0:l] + ar.tolist() + a[r:]
It may look primitive, but it involves getting a copy of the submatrix of the given array, and then preparing two more copies for adding in the left and right directions in addition to the scalar addition. I was hoping to find a more optimized way to do this. I would like the solution to be fully included in the Python list or NumPy array, but not both, as converting from one form to another as shown above, can cause serious overhead when the data is huge.
source
share