Horridly Inefficient Project Euler #14 in Python - Collatz Sequences
You should use memoization. It can be as simple as:

def next(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

lengths = {}  # n -&gt; length of sequence starting from n
lengths[1] = 1

def length(n):
    if not n in lengths:
        lengths[n] = 1 + length(next(n))
    return lengths[n]

max = 0
for n in range(1,1000000):
    l = length(n)
    if l&gt;max:
        max = l
        print n, max