how many nested for can we utilize?

Wojtek Walczak gminick at bzt.bzt
Sun Aug 17 11:08:57 EDT 2008


On Sun, 17 Aug 2008 16:39:26 +0200, Fredrik Lundh wrote:

>> A good quote I read (I can't remember who it was from, though) is "If
>> you need more than three levels of indentation, then something is
>> seriously wrong with your code." Possibly Guido himself? Anyway. If
>> you've got 100 levels of for, you're probably making things way harder
>> than they need to be.
>
> assuming 100 levels of for and 2 items in each sequence, you'll end up 
> with 1267650600228229401496703205376 iterations through the inner loop. 
>   assuming each iteration takes a picosecond, it'll take approx 40 
> billion years to run the program.

I guess that's exactly why the OP asks the question. He just wants
to start as soon as possible ;-)

-- 
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list