On 2016-03-24, BartC <b...@freeuk.com> wrote:
> On 24/03/2016 15:03, Jon Ribbens wrote:
>> On 2016-03-24, BartC <b...@freeuk.com> wrote:
>>> On 24/03/2016 14:08, Jon Ribbens wrote:
>>>> if you thought you needed to do that then most likely what you
>>>> should actually be doing is re-writing your code so you no longer
>>>> need to. However, you could do:
>>>>
>>>>     L[:] = [0] * len(L)
>>>
>>> OK, but that's just building a new list as I've already mentioned.
>>
>> No it isn't, it's replacing the elements in-place,
>
> Replace them with what, if not an entirely new list built from 
> '[0]*len(L)'? (And which would briefly require twice the memory occupied 
> by the old list, if I'm not mistaken.)

It's replacing them with elements from an entirely new list, which is
then discarded, and only the original list remains.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to