Which is More Efficient?

Dustan DustanGroups at gmail.com
Thu May 18 15:02:33 CEST 2006


I have a program that uses up a lot of CPU and want to make it is
efficient as possible with what I have to work with it. So which of the
following would be more efficient, knowing that l is a list and size is
a number?

l=l[:size]
del l[size:]

If it makes a difference, everything in the list is mutable.




More information about the Python-list mailing list