How to delete a function argument early?
问题 I'm writing a function which takes a huge argument, and runs for a long time. It needs the argument only halfway. Is there a way for the function to delete the value pointed to by the argument if there are no more references to it? I was able to get it deleted as soon as the function returns, like this: def f(m): print 'S1' m = None #__import__('gc').collect() # Uncommenting this doesn't help. print 'S2' class M(object): def __del__(self): print '__del__' f(M()) This prints: S1 S2 __del__ I