Just wondering

Gediminas Kregzde gediminas.kregzde at gmail.com
Fri May 15 13:56:08 CEST 2009


Hello,

I'm Vilnius college II degree student and last semester our teacher
introduced us to python
I've used to program with Delphi, so I very fast adopted to python

Now I'm developing cross platform program and use huge amounts of
data. Program is needed to run as fast as it coud. I've read all tips
about geting performance, but got 1 bug: map function is slower than
for loop for about 5 times, when using huge amounts of data.
It is needed to perform some operations, not to return data.

I'm adding sample code:
from time import time

def doit(i):
   pass

def main():
   a = [0] * 10000000
   t = time()
   map(doit, a)
   print "map time: " + str(time() - t)

def main2():
   t = time()
   a = [0] * 10000000
   for i in a:
       pass
   print "loop time: " + str(time() - t)

main()  # takes approximately 5x times longer than main2()
main2()

I'm wondering were is catch?

I'm using python 2.6 on windows xp sp2 machine

P.S. Sorry for my broken English



More information about the Python-list mailing list