On Tue, Feb 9, 2010 at 1:11 PM, Dhananjay Nene wrote:
> On Tue, Feb 9, 2010 at 1:03 PM, Dhananjay Nene >wrote:
>
> >
> >
> > Interestingly in my computations the second approach (zip) is about 35%
> > slower (as measured over 5 runs of 1M iterations each) than the first one
> > (map/lambda). I b
On Tue, Feb 9, 2010 at 1:03 PM, Dhananjay Nene wrote:
> Anand Balachandran Pillai wrote:
>
> On Tue, Feb 9, 2010 at 10:52 AM, Srinivas Reddy Thatiparthy
> wrote:
>
>
>
> Thanks for the replies and I avoid using lambdas..
> Btw,Shall I avoid using filter and map ?
> Because what ever filter and
>> But practicality beats purity. Given a choice, I will always use the
latter instead of the former, irrespective of the "elegance", which is
questionable and subjective anyway :)
Shall I say,Go with your personal preference in personal
projects,provided milliseconds performance is not a constra
On Tue, Feb 9, 2010 at 10:52 AM, Srinivas Reddy Thatiparthy <
srinivas_thatipar...@akebonosoft.com> wrote:
>
> Thanks for the replies and I avoid using lambdas..
> Btw,Shall I avoid using filter and map ?
> Because what ever filter and map do,I could seem to do the same with
> Listcomprehensions..
On 02/09/2010 10:37 AM, Anand Chitipothu wrote:
On Tue, Feb 9, 2010 at 10:22 AM, Srinivas Reddy Thatiparthy
[...snip...]
#1.
You can even remove the square brackets.
sum(i for i in range(1000) if i%3==0 or i%5==0)
Yes, you can but that doesn't necessarily mean it is better. Interestingly,
so
filter, map (reduce, any, all) come from the world of Functional
Programming. For that matter list comprehension was borrowed from FP
(haskell).
I wont attempt to compare them as they cater to different needs. Yes, they
overlap in certain areas but I'd like to think of them as seperate assets
suit
Thanks for the replies and I avoid using lambdas..
Btw,Shall I avoid using filter and map ?
Because what ever filter and map do,I could seem to do the same with
Listcomprehensions..
Is there any situation in which they fare better than list
comprehensions?
Regards,
~ Srini T
On Tue, Feb 9, 2010 at 10:22 AM, Srinivas Reddy Thatiparthy <
srinivas_thatipar...@akebonosoft.com> wrote:
> 1.sum([i for i in range(1000) if i%3==0 or i%5==0])
>
Slightly better would be:
sum((i for i in range(1000) if i%3==0 or i%5==0))
> 2.gen=(i for i in range(1000))
> sum([i for i in g
On Tue, Feb 9, 2010 at 10:22 AM, Srinivas Reddy Thatiparthy
wrote:
> I have written four solutions to a problem(self explanatory) ,out of
> them ,which one is the pythonic way of doing and
> is there any other ways of solving it?
>
>
> 1.sum([i for i in range(1000) if i%3==0 or i%5==0])
>
> 2.g
I have written four solutions to a problem(self explanatory) ,out of
them ,which one is the pythonic way of doing and
is there any other ways of solving it?
1.sum([i for i in range(1000) if i%3==0 or i%5==0])
2.gen=(i for i in range(1000))
sum([i for i in gen if i%3==0 or i%5==0])
3.s
10 matches
Mail list logo