Bit manipulation
MethodBit manipulation computes with binary representations using operations such as shifts, masks, and bitwise logic.
In plain terms: Working directly with the ones and zeros of a number using shifts, masks, and AND, OR, XOR to pack flags or compute things fast.
For example: XOR of all numbers in a list where every value appears twice except one returns the single value in O(n) time and O(1) space.
Read
Docs
- Python integer bitwise operations (opens in a new tab)Python Software Foundation
About this resource
Specifies shifts, bitwise operators and the integer model that determines their behavior.
Where to read: Bitwise Operations on Integer Types
Checked 2026-10-08
Authority for this purpose: Python Software Foundation publishes this first-party source.
Destination inspection: Bounded public-address-pinned GET followed by destination text and concept-scope inspection
Useful destination; no explanatory claim is asserted from this link.
- Implementation-specific behavior; this source does not establish comparative superiority.
Reviewed authoritative resource
Where to read: Bitwise Operations on Integer Types
A first-party destination supports its documented scope; it does not establish independent performance validation or historical priority.
Related concepts
Broader
- AlgorithmsKnowledge area
Related
- Model quantizationMethod
Asked in interviews
Books to go deeper
Introduction to Algorithms
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein · 4th edition
Data structures, algorithm design and asymptotic reasoning.
View on Amazon (affiliate link) ↗The Pragmatic Programmer
David Thomas and Andrew Hunt · 20th anniversary, 2nd edition
Design, debug and maintain software with explicit contracts and feedback.
View on Amazon (affiliate link) ↗As an Amazon Associate I earn from qualifying purchases.
Loading discussion…
