preferred syntax for list extend?

bvdpoel at uniserve.com bvdpoel at uniserve.com
Tue Apr 16 20:28:06 EDT 2002


Just doing a bit of fooling around and I've found that if:

	q1=[1,2,3,4]
	q2=[5,6,7,8]

then:
	
	q1 += q2

is about 15% faster than

	q1.extend(q2)

Mind you, my test was with a relatively short list, don't know if longer
lists would act differently.

I would have thought that using extend() would be preferred and faster?

-- 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bvdpoel at uniserve.com
WWW:   http://users.uniserve.com/~bvdpoel




More information about the Python-list mailing list