Gediminas Kregzde wrote:
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
===============================
cut n paste done
Using Laptop at 2.4 GHz
map time: 4.9281001091 map/loop = 5.7554...
loop time: 0.856245994568
Using Desktop at 3.1 GHz
map time: 3.46799993515 map/loop = 7.6556...
loop time: 0.453000068665
Yep - map is way slower
Your English is good enough for me to understand. What more is needed?
:)
Someone writing Python can probably say why.
Steve
--
http://mail.python.org/mailman/listinfo/python-list