R
rantingrick
Everyone knows i'm a Python fanboy so nobody can call me a troll for
this...
Python map is just completely useless. For one it so damn slow why
even bother putting it in the language? And secondly, the total "girl-
man" weakness of lambda renders it completely mute!
Ruby has a very nice map
Have not done any benchmarking but far more useful from the
programmers POV. And that really stinks because map is such a useful
tool it's a shame to waste it. Here are some test to back up the rant.
l = range(10000)
t1 = time.time()
map(lambda x:x+1, l)
t2= time.time()
print t2-t1
l = range(10000)
t1 = time.time()
for x in l:
x + 1
t2 = time.time()
print t2-t1
l = range(10000)
t1 = time.time()
map(str, l)
t2= time.time()
print t2-t1
l = range(10000)
t1 = time.time()
for x in l:
str(x)
t2= time.time()
print t2-t1
So can anyone explain this poor excuse for a map function? Maybe GVR
should have taken it out in 3.0? *scratches head*
this...
Python map is just completely useless. For one it so damn slow why
even bother putting it in the language? And secondly, the total "girl-
man" weakness of lambda renders it completely mute!
Ruby has a very nice map
[1,2,3].map{|x| x.to_s}
Have not done any benchmarking but far more useful from the
programmers POV. And that really stinks because map is such a useful
tool it's a shame to waste it. Here are some test to back up the rant.
l = range(10000)
t1 = time.time()
map(lambda x:x+1, l)
t2= time.time()
print t2-t1
l = range(10000)
t1 = time.time()
for x in l:
x + 1
t2 = time.time()
print t2-t1
l = range(10000)
t1 = time.time()
map(str, l)
t2= time.time()
print t2-t1
l = range(10000)
t1 = time.time()
for x in l:
str(x)
t2= time.time()
print t2-t1
So can anyone explain this poor excuse for a map function? Maybe GVR
should have taken it out in 3.0? *scratches head*