[Python-Dev] List copy and clear (was Re: Inconsistent API for sets.Set and build-in set)
Tim Peters
tim.peters at gmail.com
Fri Jul 1 00:20:38 CEST 2005
[Raymond Hettinger]
>> the current idiom:
>>
>> mylist[:] = [] # clear
[Fred L. Drake, Jr.]
> Unless you happen to prefer the other current idiom:
>
> del mylist[:]
Or my personal favorite,
while mylist:
del mylist[::2]
Then the original index positions with the most consecutive trailing 1
bits survive the longest, which is important to avoid ZODB cache bugs
<wink>.
More information about the Python-Dev
mailing list