List comprehensions. They’re usually faster than equivalent for loops and don’t leave any state hanging around. And they have less LOC. Sometimes map can be faster, depending on what you’re doing (invoking functions is costly either way, so list comprehensions that allow you to remove lambdas are a win).
Further discussion here
General loop optimisation, straight from Guido himself:
And general tips:
And now we have generator expressions, which often provide even further improvements. I believe Python 2.4 and up support them.
for n in (x ** 2 for x in range(10)):