0

what is the fastest way to invert particular bits in all of the bytes within a byte array? I want to invert bits on these positions 0b00110011. Now I am doing it this way but for long array it's pretty slow.

for i in range(len(byte_array_np)):
    byte_array_np[i] &= 0x77
    byte_array_np[i] ^= 0x33

Thank you for sugestions.

wjandrea
  • 28,235
  • 9
  • 60
  • 81

0 Answers0