Nested loop limit?

Larry Bates lbates at swamisoft.com
Wed Jul 7 15:18:01 EDT 2004


Peter already answered your "specific" question, but
I thought I'd make a suggestion.  If you find yourself
with LOTS of nested loops, you probably need to take
a closer look at your class/data structure.  Often I
find that if I find that I'm looping a lot, I probably
haven't optimized my data storage or object structures
well.  Using list comprehensions can effectively eliminate
many loops, but your data must be structured in lists of
numbers (or objects) for them to work well.  Functions
that act on lists of objects can also eliminate many
nested loops.  Lists of objects that themselves hold lists
of objects can allow you to create complex hierarchies that
don't require lots of nested lists.

Just some thoughts that might be of benefit.

Regards,
Larry Bates
Syscon, Inc.


"chad" <chad.himeda at hp.com> wrote in message
news:fd07865f.0407071045.16e20c84 at posting.google.com...
> I am writing a program to do some reliability calculations that
> require several nested for-loops.  However, I believe that as the
> models become more complex, the number of required for-loops will
> increase.  Does Python have a limit on the number of nested for-loops?
>  Thanks.





More information about the Python-list mailing list