All pastes #191710 Raw Edit

timmeh

public python v1 · immutable
·published 2006-10-05 07:59 UTC
rendered paste body
import time, operatordef addvec1(vec1, vec2):	return [vec1[0] + vec2[0], vec1[1] + vec2[1], vec1[2] + vec2[2]]def addvec2(vec1, vec2):	return map(operator.add, vec1, vec2)a = time.clock()for x in range(100000):	addvec1([1,2,3],[2,3,4])	b = time.clock() - aa = time.clock()for x in range(100000):	addvec2([1,2,3], [2,3,4])	c = time.clock() - aprint 'addvec1 using addition manually:', bprint 'addvec2 using map statement:', c