def bitwise_reverse(int_src): bin_str = bitstring.pack('uint:8',int_src).bin ret = "".join(map(lambda x: "1" if x == "0" else "0", bin_str)) return int(ret, 2)