copy a list

Yuval yuvalfeld at hotmail.com
Mon Mar 10 08:33:55 CET 2003


Hi, 
I have to work on a list without changing it. Specifically, in every
iteration I have to choose an object and remove it in the end of that
iteration, repeat it until the list is empty. However, I do not want
to touch the list itself since I need to repeat this process many
times (start over again once the list is empty). Therefore, in order
to "play around" with a list A, I create a copy of it: B = A[:].
My problem is that it slows down my program siginificantly. Is it a
common problem with that operation? Is there an alternative way of
soing it?

Thanks.




More information about the Python-list mailing list