Timing Difference: insert vs. append & reverse

Duncan Smith buzzard at urubu.freeserve.co.uk
Mon Aug 2 13:04:29 EDT 2004


"John Keeling" <johnfkeeling at yahoo.com> wrote in message
news:35b736b9.0408020330.53b24ed3 at posting.google.com...
> Dear all,
> I tried the test program below. My interest is to examine timing
> differences between insert vs. append & reverse for a list. My results
> on my XP Python 2.3.4 are as follows:
> time_reverse  0.889999389648
> time_insert  15.7750005722
> Over multiple runs ... the time taken to insert at the head of a list,
> vs. the time taken to append to a list and then reverse it is
> typically 16 or 17 times longer.

Shouldn't that really be insert vs. reverse & append & reverse. :-)

Duncan




More information about the Python-list mailing list