title: Python - Delete (remove from memory) a variable from inside a function?
body: <p>I have to load this massive object <code>A</code> (that can weight almsot 10go) that I need to pass to a function, that extracts from it a parameter <code>B</code> to further exert some heavy computations on it.</p>
  
  <pre><code>A = load(file)
  
  def function(A):    
     B = transorm(A)    
     B = compute(B)
     return(B)
  </code></pre>
  
  <p>In order to free some memory (as I already had a MemoryError), I'd like to remove <code>A</code> from memory right after its transformation to B.
  I tried <code>del</code> but it doesn't seem to affect the existence of <code>A</code> at the script level. I also tried <code>del global()["A"]</code> but it says that A is not defined as a global variable.</p>
  
  <p>Is there a way to do it? Thanks!</p>