Re: Which is faster?



On Aug 30, 5:30 pm, cnb <circularf...@xxxxxxxx> wrote:
how does doing something twice not change complexity? yes it maybe
belongs to the same complexity-class but is still twice as slow no?

Who is doing something twice? Definitely not sum().

sum() does not create intermediate list, and if you pass generator
expressions in it you wouldn't make any intermediate list at all, thus
simple looping but in interpreter code. sum() that is passed a list
comprehension should be faster for extremely small numbers of values
to sum, but we don't care about small things, do we? But using
intermediate list should be fast enough for even large numbers of
values, the time when it can't cope anymore would be when the
intermediate list takes half of your memory (how often is that for
regular applications?).
.



Relevant Pages

  • Re: OOP/OOD Philosophy
    ... access will be duplicatied and the report twice as slow. ... But if the sum is printed in the footer of the report, ... important that the sum is the sum of the printed items and nothing ...
    (comp.object)
  • Re: adding colums to text
    ... Bill Cunningham wrote: ... I am trying to create a moving average of data. ... asked at least twice, if only indirectly. ... number from the corresponding input line, followed by the sum of all ...
    (comp.lang.c)
  • Re: adding colums to text
    ... Bill Cunningham wrote: ... I am trying to create a moving average of data. ... asked at least twice, if only indirectly. ... number from the corresponding input line, followed by the sum of all ...
    (comp.lang.c)
  • Re: My Election Odds for MZB
    ... My mistake was in only offering to match the sum of the bet. ... I will now offer TWICE the ... amount if Bob T. stiffs Irish Mike. ...
    (rec.gambling.poker)
  • Re: Which is faster?
    ... belongs to the same complexity-class but is still twice as slow no? ... Who is doing something twice? ... Definitely not sum(). ... two passes over the source sequence, ...
    (comp.lang.python)