We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The main difference I can see that can have an effect on the speed is that I
1. changed the placeholder to None
2. moved the population into a method. Local lookups are faster than global lookups
3. used range iterators for the inner loops instead of range lists
I think [2.] or changing for j in range(1, i + 1): to for j in xrange(1, i + 1): will have the largest impact
Down to Zero II
You are viewing a single comment's thread. Return to all comments →
This code works in Python 3:
The main difference I can see that can have an effect on the speed is that I 1. changed the placeholder to None 2. moved the population into a method. Local lookups are faster than global lookups 3. used range iterators for the inner loops instead of range lists
I think [2.] or changing for j in range(1, i + 1): to for j in xrange(1, i + 1): will have the largest impact