def bits_to_indices(mask):
    """Generate list of indices of bits set to one in the value."""
    i = 1
    while mask > 0:
        if bool(mask & 1):
            yield i
        mask >>= 1
        i += 1
    return
