I have to work with big arrays, says for example x = np.arange(0, 750*350*365, dtype=np.int32)
I know python hold a variable in memory as long as it has at least one reference to it.
But lets say i have to import a big array, do some math on it, and save a smaller array computed from the big one. Would the big array still be on memory ?
For example :
Class Data:
value = None
def process(myDataInstance):
x = np.arange(0, 750*350*365, dtype=np.int32)
ix = numpy.where(x < 50000)
myDataInstance.value = x[ix]
d = Data()
process(d)
(in real life, i'm not creating array in the function but loading a file which contains large arrays, but this is for example purpose)
will be x
still in memory even if we aren't anymore in the 'process' function ?
Edit : i know x will not be reachable as if I type print x
outside the function, there will be an error because he was defined in the scope of the function. I'm asking about memory and reference instead of variable name.
If yes, should i use myDataInstance.value = x[ix].copy()
to create another array so the reference would be deleted when leaving the function ?
If no, where does it copy it ?
Thanks for the explanation