Is this an efficient way to generate the Thue-Morse sequence in Python?
Question: Is using a generator as in the code below, an efficient way to generate the
[Thue-Morse
sequence](http://en.wikipedia.org/wiki/Thue%E2%80%93Morse_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))
    


Answer: This is concise, is it "efficient"?

    
    
    import itertools
    
    def genThueMorse():
        for n in itertools.count():
            yield (1 if bin(n).count('1')%2 else 0)
    

