This is driving me nuts. The following code is basically the question. The first part halts almost immediately. The second seems to get stuck. However, they should be doing the exact same thing, since one == two
.
one = [[(0,)]] + [[], [], [], [], [], [], [], [], []]
n = 9
two = [[(0,)]] + ([[]] * n)
if (one == two):
print "It is indeed the same thing!"
print "Fast:"
strings = one
print str(strings)
for j in range(0, n):
for i in strings[j]:
strings[j + 1].append(i + (0,))
strings[j + 1].append(i + (1,))
print "Slow:"
strings = two
print str(strings)
for j in range(0, n):
for i in strings[j]:
strings[j + 1].append(i + (0,))
strings[j + 1].append(i + (1,))