Python : efficient bytearray incrementation
Question: How to iterate all possible values of `bytearray of length = n` in Python ? in
worst case `n <= 40bytes`

For example, iterate for `n = 4` :

    
    
    00000000 00000000 00000000 00000000
    00000000 00000000 00000000 00000001
    00000000 00000000 00000000 00000010
    
    .
    .
    .
    .
    
    11111111 11111111 11111111 11111110
    11111111 11111111 11111111 11111111
    


Answer: You can use `itertools.product`:

    
    
    In [11]: from itertools import product
    
    In [15]: for x in product('01',repeat=4): #for your n=4 change repeat to 32 
        print "".join(x)
       ....:     
    0000
    0001
    0010
    0011
    0100
    0101
    0110
    0111
    1000
    1001
    1010
    1011
    1100
    1101
    1110
    1111
    

