Which is More Efficient?

Ben Finney bignose+hates-spam at benfinney.id.au
Thu May 18 09:15:17 EDT 2006


"Dustan" <DustanGroups at gmail.com> writes:

> 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.

Profile your program and find the precise parts that are the
slowest. Attempting to optimise before that is a waste of your time.

> 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:]

Which one is more efficient in your program, when you profile its
performance?

    <URL:http://docs.python.org/lib/profile.html>

-- 
 \       "Working out the social politics of who you can trust and why |
  `\      is, quite literally, what a very large part of our brain has |
_o__)                                evolved to do."  -- Douglas Adams |
Ben Finney




More information about the Python-list mailing list