Dave Angel wrote:
norseman wrote:
Marco
Mariani wrote:
Gediminas Kregzde wrote:
def doit(i):
pass
def main():
a = [0] * 1000
t = time()
map(doit, a)
print "map time: " + str(time() - t)
Here you are calling a function ten million times, build a list with
of ten million
norseman wrote:
Marco
Mariani wrote:
Gediminas Kregzde wrote:
def doit(i):
pass
def main():
a = [0] * 1000
t = time()
map(doit, a)
print "map time: " + str(time() - t)
Here you are calling a function ten million times, build a list with
of ten million None results, then
Marco Mariani wrote:
Gediminas Kregzde wrote:
def doit(i):
pass
def main():
a = [0] * 1000
t = time()
map(doit, a)
print "map time: " + str(time() - t)
Here you are calling a function ten million times, build a list with of
ten million None results, then throw it away.
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
Jaime Fernandez del Rio wrote:
>> (1) building another throwaway list and
>> (2) function call overhead for calling doit()
>>
>> You can avoid (1) by using filter() instead of map()
>
> Are you sure of this?
> I'm afraid there is no builtin function to do an inplace modification
> of a sequence
Gediminas Kregzde a écrit :
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 f
> (1) building another throwaway list and
> (2) function call overhead for calling doit()
>
> You can avoid (1) by using filter() instead of map()
Are you sure of this? My python returns, when asked for help(filter) :
Help on built-in function filter in module __builtin__:
filter(...)
filter
Gediminas Kregzde wrote:
> 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.
map is creating a new list of 10,000,000 items, not modifying the
values inside list a. That's probably where your time difference comes
from...
Jaime
On Fri, May 15, 2009 at 1:56 PM, Gediminas Kregzde
wrote:
> Hello,
>
> I'm Vilnius college II degree student and last semester our teacher
> intr
Gediminas Kregzde wrote:
def doit(i):
pass
def main():
a = [0] * 1000
t = time()
map(doit, a)
print "map time: " + str(time() - t)
Here you are calling a function ten million times, build a list with of
ten million None results, then throw it away.
def main2():
t =
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 ( 1000 )
b = a + 3.14
print "loop time: " + str(time() - t)
cheers,
Stef
Gediminas Kreg
Gediminas Kregzde:
> 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.
Then you are using map() for the wrong purpose. map() purpose is to
build a list of things. Use a for loop.
Bye,
bearophil
12 matches
Mail list logo