lookup complexity fix + pyversion portability

+ Changed is_reg lookup from * in self.regs.keys() to * in self.regs, O(n) to O(1).
+ Converted print and *range iterator to support pyversions >= 2.6