list problem

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Sep 24 09:00:27 EDT 2002


Alex Martelli <aleax at aleax.it> wrote in 
news:tCYj9.157570$pX1.5675986 at news2.tin.it:

>> If you are going to use reduce, then you would be better off writing:
>> 
>>    import operator
>>    reduce(operator.add, x)
> 
> Maybe (marginally).  But timing things is often a good idea:

Apologies for not being clearer. I actually felt that using operator.add 
read more cleanly than using a lambda. I should have made it more obvious 
that was what I meant. I wouldn't particularly worry which is faster unless 
one was actually proven to be a bottleneck, at which point the OP might 
well find the best way to optimise would be to not end up with nested lists 
in the first place.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list