Nested loop limit?
Terry Reedy
tjreedy at udel.edu
Sun Jul 11 16:00:07 EDT 2004
"Bengt Richter" <bokr at oz.net> wrote in message
news:ccrucm$qbv$0 at 216.39.172.122...
> How many total executions of the innermost loop are you expecting?
>
> At 2 states per nested loop, ISTM you'd have 2**20 unless some logic
prunes it (not bad).
And there are at least two simple ways to extend the limit: a) have the
innermost loop call a function with its own set of nestings; b) flatten the
nesting with explicit cross-products, as in replacing
for a in [1,2]:
for b in [1,2]: # with
for a,b in [(1,1), (1,2), (2,1), (2,2)]:
Terry J. Reedy
More information about the Python-list
mailing list