Alex Martelli wrote: > You should probaby prepare before the loop a mapping from char to number > of 1 bits in that char: > > m = {} > for c in range(256): > m[c] = countones(c) Wouldn't a list be more efficient? m = [countones(c) for c in xrange(256)]