In article <[EMAIL PROTECTED]>,
runsun pan <[EMAIL PROTECTED]> wrote:
.
.
.
>Secondly, [x+y for x,y in itertools.izip(xs, ys)] did go much faster
>than map(lambda x,y: x+y, xs, ys). The latter is not only the slowest
>one, but
Thx, Robert. I did some tests:
>>> xs = range(1)
>>> ys = range(0,2,2)
>>> def m1(x, count=100):
... for c in range(count):
...y = map(float, x)
... return y
>>> def L1(x, count=100):
... for c in range(count):
...y = [float(z) for z in x]
... return y
>>> d
runsun pan wrote:
I remember reading somewhere that the map, filter, reduce are much
faster than list comp.
It depends.
map(float, some_list_of_numbers)
is going to be faster than
[float(x) for x in some_list_of_numbers]
but
map(lambda x,y: x+y, xs, ys)
is going to be slower than
import ite
I remember reading somewhere that the map, filter, reduce are much
faster than list comp.
--
http://mail.python.org/mailman/listinfo/python-list
I very much take your point. And thanks: that answers my syntax
question (I think!) -- *and* tells me that I don't care.
Charles Hartman
On Mar 27, 2005, at 2:16 PM, [EMAIL PROTECTED] wrote:
...
>>> simpler == complexities
True
>>>
I've not the glimmer of a clue which would be faster, and don't c
Brian van den Broek said unto the world upon 2005-03-27 14:12:
Charles Hartman said unto the world upon 2005-03-27 13:35:
On Mar 27, 2005, at 1:18 PM, Brian van den Broek wrote:
>>> def some_arbitrary_function(y):
... return ( (y * 42) - 19 ) % 12
...
>>> [some_arbitrary_function(len(x)) for x
Charles Hartman said unto the world upon 2005-03-27 13:35:
On Mar 27, 2005, at 1:18 PM, Brian van den Broek wrote:
>>> def some_arbitrary_function(y):
... return ( (y * 42) - 19 ) % 12
...
>>> [some_arbitrary_function(len(x)) for x in lines.split()]
[5, 5, 11, 11, 5, 11, 5, 11]
>>>
I could be m
On Mar 27, 2005, at 1:18 PM, Brian van den Broek wrote:
>>> def some_arbitrary_function(y):
... return ( (y * 42) - 19 ) % 12
...
>>> [some_arbitrary_function(len(x)) for x in lines.split()]
[5, 5, 11, 11, 5, 11, 5, 11]
>>>
I could be missing some edge cases, but it seems to me that if you
hav
Charles Hartman said unto the world upon 2005-03-27 09:51:
I understand this toy example:
lines = "this is a group\nof lines of\nwords"
def getlength(w): return len(w)
s = map(getlength, [word for ln in lines.split() for word in
ln.splitlines()])
(now s is [4, 2, 1, 5, 2, 5, 2, 5])
My question i
Charles Hartman wrote:
> On Mar 27, 2005, at 11:50 AM, Nicolas Évrard wrote:
>
>>>
>>> I hope the question is clear enough. I have a feeling I'm ignoring a
>>> simple technique . . .
>>
>> lambda !
>>
>> map(lambda x: timestwo(getlength(x)), ...)
>
> Ah, lambda! I've heard so much bad-mouthing
On Mar 27, 2005, at 11:50 AM, Nicolas Évrard wrote:
I hope the question is clear enough. I have a feeling I'm ignoring a
simple technique . . .
lambda !
map(lambda x: timestwo(getlength(x)), ...)
Ah, lambda! I've heard so much bad-mouthing of lambda that I forgot to
learn it . . . This is quite
* Charles Hartman [16:51 27/03/05 CEST]:
I understand this toy example:
lines = "this is a group\nof lines of\nwords"
def getlength(w): return len(w)
s = map(getlength, [word for ln in lines.split() for word in
ln.splitlines()])
(now s is [4, 2, 1, 5, 2, 5, 2, 5])
My question is whether there'
I understand this toy example:
lines = "this is a group\nof lines of\nwords"
def getlength(w): return len(w)
s = map(getlength, [word for ln in lines.split() for word in
ln.splitlines()])
(now s is [4, 2, 1, 5, 2, 5, 2, 5])
My question is whether there's any compact way to combine function
cal
13 matches
Mail list logo