map-like function on dict values?

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Thu Feb 28 20:22:47 EST 2002


On 1 Mar 2002 00:03:38 +0100, Carel Fellinger <cfelling at iae.nl> wrote:
>Skip Montanaro <skip at pobox.com> wrote:
>...
>> Don't assume for loop iteration is your only culprit... ;-) List creation
>> overhead can be as big a problem.  I added another test function called iter
>
>yep, see my other posting:)

Thank you both for 
1) convincing me to install 2.2 (even the same algorithm speeds up 6-7%)
2) altogether speeding it up seven times over my initial version

>Ah a new contestent, double fun, better algoritme better timing (linux
>too), but the real iter still wins, although by a very slight margin:)

>iter 10.95
>iteriteritems 10.43
>iteritems 52.15
>mapvalue 12.88

They are very similar, to say the least.  In any case, the remainder time
seems mostly function call overhead.  Here's my result (also linux).

def emptyloop(f, d):
	for i in xrange(len(d)):		pass

def emptyloopcall(f, d):
	for i in xrange(len(d)):		f(None)

emptyloop 0.67
emptyloopcall 2.39
iter 2.87
iteriteritems 2.94
iteritems 18.63
mapvalue 3.94


Huaiyu



More information about the Python-list mailing list