Profiling, sum-comprehension vs reduce
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sat Sep 13 04:25:46 EDT 2008
On Sat, 13 Sep 2008 01:06:22 -0700, cnb wrote:
> This must be because of implementation right? Shouldn't reduce be faster
> since it iterates once over the list? doesnt sum first construct the
> list then sum it?
No it doesn't. Why should it?
> also, using range instead of xrange doesnt seem to generate a
> performance-penalty:
(De)Allocating a list of length 100 isn't very slow. Try some million
elements. And watch the memory consumption too.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list