I'm reading through a tutorial for a Python based trading platform, and it is recommending the use of bitwise (~
, &
, |
) rather than boolean (not
, and
, or
) operators for combining boolean expressions.
Like factors, filters can be combined. Combining filters is done using the
&
(and) and|
(or) operators.
Is there a good reason for this? I've never seen it before. I am not entirely sure about all the properties of booleans in Python but I do believe that in C and C++ booleans are represented by an integer 1 or 0 and can be operated on as such. Is Python similar? I can see how an &
and an |
at least could work in that case.
What could be the purpose for using these bitwise operators instead of boolean? Is it faster?