anonymous assignment
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue May 13 04:29:24 EDT 2008
En Tue, 13 May 2008 00:21:06 -0300, Yves Dorfsman <yves at zioup.com>
escribió:
> 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.
If you have some reasons to believe it's worth to release that last
reference as soon as possible, just do it. `del _` is all you need.
(I may have used `del` to remove a local name no more than once a year...)
--
Gabriel Genellina
More information about the Python-list
mailing list