[Python] Fast bitwise (a & ~b), ~(a & b) etc. in Python [closed]

Discussão em 'Python' iniciado por Stack, Setembro 24, 2024.

  1. Stack

    Stack Membro Participativo

    Is there an existing Python library that directly supports all binary bitwise operations with ints?

    Python has binary bitwise operations "and" (a & b), "xor" (a ^ b), "or" (a | b) and unary "not" (~ a). Formulas like (a & ~b), (a | ~b), (a ^ ~b), ~(a & b), ~(a | b) involve two or more operations and are less efficient. I'm looking for an existing library that has a single operation for each of them with (a & ~b) is as fast as (a & b) and so on.

    Continue reading...

Compartilhe esta Página