anonymous assignment

Yves Dorfsman yves at zioup.com
Mon May 12 23:21:06 EDT 2008


Ben Finney wrote:

>>>    y, _, d, _, _, _, _, _, _ = time.localtime()
>> But you still have have a variable that's using memory for nothing.
> 
> No, you have one extra unused name binding. The values that you don't
> want to use have *already* been allocated by the time the above
> statement is executed. Name binding doesn't copy the values, it merely
> binds a name to them. There's no "variable" in the above statement.
> 

But if this happens in the main part of your script, it could take a long 
time before this binding disapear, therefore, the gc won't be able to clean 
that one up. In this particular case, it doesn't really matter (small size), 
but imagine in a case where we are talking of a list of list, with 
potentially large element in the list.


Yves.



More information about the Python-list mailing list