Re: [Tutor] How inefficient is this code?

2014-05-08 Thread Joe Cortes
n chime in. On Wed, May 7, 2014 at 8:39 PM, C Smith wrote: > On Wed, May 7, 2014 at 7:55 PM, Joe Cortes wrote: >> Welcome to the wonderful world of generators! >> >> Looking at your code, you'll notice two things. First, you're >> iterating over all the numb

Re: [Tutor] How inefficient is this code?

2014-05-08 Thread Joe Cortes
Welcome to the wonderful world of generators! Looking at your code, you'll notice two things. First, you're iterating over all the numbers twice: once to calculate them, and then another time to actually do the sum. What's worse, at any given point in time, you're only really using fibs[-1] and fi