map vs. list-comprehension
Mandus
mandus at gmail.com
Thu Jun 30 08:41:30 EDT 2005
Wed, 29 Jun 2005 08:33:58 -0700 skrev Scott David Daniels:
> Mandus wrote:
>> 29 Jun 2005 10:04:40 GMT skrev F. Petitjean:
>>
>>>Le Wed, 29 Jun 2005 09:46:15 +0000 (UTC), Mandus a écrit :
>>>
>>>res = [ bb+ii*dd for bb,ii,dd in zip(b,i,d) ]
>>
>> seem to be a tad slower than the map, but nothing serious. Guess it's
>> the extra zip.
> You could try timing it using itertools.izip rather than zip.
jepp - faster, but still slower than the map.
1000000 iterations:
zip+list-comprehension: 8.1s
izip+list-comprehension: 7.5s
map: 7.0s
--
Mandus - the only mandus around.
More information about the Python-list
mailing list