Is using a generator as in the code below, an efficient way to generate the Thue-Morse sequence in Python?
# generate the Thue-Morse sequence
def genThueMorse():
    # initialize
    tms = '0'
    curr = 0
    while True:
        # generate next sequence
        if curr == len(tms):
            tmp = ''
            for i in range(len(tms)):
                if tms[i] is '0':
                    tmp += '1'
                else:
                    tmp += '0'
            tms += tmp
        yield tms[curr]
        curr +=1
Here is code to test it:
tms = koch.genThueMorse()
while True:
   print(next(tms))
 
     
     
    