In Python 2.7 (and Python3) we can replace this line with
```ind = n - (_old ^ _new).bit_length() - 1```
Since we require at least Python 2.7 for the labs anyway, this is guarenteed to be compatible.  I would probably subtract an extra 1 from the value of n before the value of the loop as it would save ever so slightly on the execution speed.
On my machine, the execution went from 990ms to 279ms by changing this line (this is the gray codes of a list of 20 elements).