[Tutor] Efficiency and speed

Stefan Behnel stefan_ml at behnel.de
Sat Mar 20 07:51:50 CET 2010

James Reynolds, 19.03.2010 21:17:
> Here's another idea I had. I thought this would be slower than then the
> previous algorithm because it has another for loop and another while loop. I
> read that the overhead of such loops is high, so I have been trying to avoid
> using them where possible.

Premature optimisation is the source of all evil.

>      def mcrange_gen(self, sample):
>          nx2 = self.nx1
>          for q in sample:
>              for a in nx2:
>                  while a>  q:
>                       pass

Looks like an infinite loop to me.


More information about the Tutor mailing list