Just wondering
Stef Mientki
stef.mientki at gmail.com
Fri May 15 08:21:27 EDT 2009
and this, while it's realy doing something is even 4 times faster than
main2 ;-)
And if you only need integers, it can be even faster.
def main3():
from numpy import zeros
t = time()
a = zeros ( 10000000 )
b = a + 3.14
print "loop time: " + str(time() - t)
cheers,
Stef
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
>
More information about the Python-list
mailing list