[1]: https://docs.python.org/3/library/stdtypes.html#int.bit_coun...
[1]: https://docs.python.org/3/library/stdtypes.html#int.bit_coun...
Edited, more info: AMD's Barcelona architecture introduced the advanced bit manipulation (ABM) ISA introducing the POPCNT instruction as part of the SSE4a extensions in 2007. Intel Core processors introduced a POPCNT instruction with the SSE4.2 instruction set extension, first available in a Nehalem-based Core i7 processor, released in November 2008.
https://www.researchgate.net/figure/Census-transform-and-Ham...
- A bitset index
- Bitflags (e.g. to represent logging levels)
- Feature flags
`bit_count` (aka `popcount`) gives you an efficient way to figure out how many bits within those structures are set and not set.
I guess it's included as an easy way to access the fast hardware supported implementation, on architectures where it is available.
This article has a lot of interesting examples. https://vaibhavsagar.com/blog/2019/09/08/popcount/